INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How do I get a Timestamp value from an inserted record?

How do I get a Timestamp value from an inserted record?

How do I get a Timestamp value from an inserted record?

(OP)
I have a procedure that inserts a record into a table and I need to return the timestamp from the insertion back to the calling java program. As I am relatively new to DB2 I am not sure how to do this. I have search the web for any info on this but, have not had any success.

CODE --> sql

CREATE PROCEDURE "ATS"."MVP_ASC_INSERT" ( 
	IN "P_SM_ACCOUNT_ID" VARCHAR(8),
        IN "P_USER_ID" VARCHAR(30),
	OUT "P_CREATED_TIMESTAMP" TIMESTAMP
)
  LANGUAGE SQL
  MODIFIES SQL DATA
  CALLED ON NULL INPUT
  INHERIT SPECIAL REGISTERS
BEGIN

  INSERT INTO ATS_SYSTEM_CONTACTS
     (ACCOUNT_ID, USER_ID, CREATED_TIMESTAMP)
  VALUES 
     (P_SM_ACCOUNT_ID, P_USER_ID, CURRENT TIMESTAMP);

END; 

RE: How do I get a Timestamp value from an inserted record?

Possibly, read the newly created row retrieving the timestamp to return to the calling program.

RE: How do I get a Timestamp value from an inserted record?

Select the current timestamp into p_created_timestamp (is that some kind of Hungarian notation?). Then use p_created_timestamp in the value clause of the insert instead of current_timestamp.

Steve

"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::PerlDesignPatterns)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close