View previous topic :: View next topic
|
Author |
Message |
dipanshu
New User
Joined: 16 Jan 2006 Posts: 53 Location: pune
|
|
|
|
I want to insert the value for a field named TIMESTAMP in DB2 table
My confusion is whether this field take the value automatically or i have to pass it from cobol by using
Accept ws-TS from timestamp
would it work or not
Pls suggest
Thanks
Dipanshu |
|
Back to top |
|
|
elonics
New User
Joined: 05 Jul 2005 Posts: 49 Location: India
|
|
|
|
Hai Friend,
You definitely need to write function which will fetch you current timestamp in your coding and that should be moved explicitly to Db2 table while inserting.
Correct me if i am wrong.
Udaykiran,
NeSt IT, Cochin. |
|
Back to top |
|
|
dipanshu
New User
Joined: 16 Jan 2006 Posts: 53 Location: pune
|
|
|
|
Hi uday,
Thanks for reply,
Could u pls tell me how to code that function
accept ws-ts from timestamp
is it correct
thanks,
Dipanshu |
|
Back to top |
|
|
elonics
New User
Joined: 05 Jul 2005 Posts: 49 Location: India
|
|
|
|
Hai Dipanshu,
Using ACCEPT verb we cannot directly retrieve the timestamp. So what you do is retrieve Date and Time independently as
PROCEDURE DIVISION.
ACCEPT WS-CURRENT-DATE FROM DATE
ACCEPT WS-TIME FROM TIME
Move the accepted values to a declared timestamp working storage variable. Here is the working storage declaration for timestamp,
01 WS-TIMESTAMP.
05 WS-TS-CC PIC X(2).
05 WS-TS-YY PIC X(2).
05 FILLER PIC X(1) VALUE '-'.
05 WS-TS-MM PIC X(2).
05 FILLER PIC X(1) VALUE '-'.
05 WS-TS-DD PIC X(2).
05 FILLER PIC X(1) VALUE '-'.
05 WS-TS-HH PIC X(2).
05 FILLER PIC X(1) VALUE '.'.
05 WS-TS-MIN PIC X(2).
05 FILLER PIC X(1) VALUE '.'.
05 WS-TS-SS PIC X(2).
05 FILLER PIC X(1) VALUE '.'.
05 WS-TS-NN PIC X(2).
05 FILLER PIC X(4) VALUE '0000'.
Correct me if i am wrong
Udaykiran. |
|
Back to top |
|
|
elonics
New User
Joined: 05 Jul 2005 Posts: 49 Location: India
|
|
|
|
Instead of all this, you simply retrieve from IBM utilities.
SELECT CURRENT TIMESTAMP
INTO :WS-CURR-TS
FROM SYSIBM.SYSDUMMY1
This will simply do ur work.
Udaykiran.M |
|
Back to top |
|
|
nrsmca
New User
Joined: 25 May 2005 Posts: 14
|
|
|
|
We can use timestamp directly...
INSERT INTO TABLE1
(NAME,AGE,TIMSTP)
VALUSE
(:NAME,:AGE,CURRENT_TIMESTAMP);
Hope It will work 5n...
Thanks,
nrsmca. |
|
Back to top |
|
|
dipanshu
New User
Joined: 16 Jan 2006 Posts: 53 Location: pune
|
|
|
|
Hi ,
INSERT INTO TABLE1
VALUES
(:NAME,:AGE,CURRENT_TIMESTAMP);
Could anyone confirm the above query
thanks
Dipanshu |
|
Back to top |
|
|
babuprasad_g Currently Banned New User
Joined: 26 May 2005 Posts: 45 Location: gurgaon
|
|
|
|
Hi Friends,
First we need to declare the variables in working storage section.
For Getting TimeStamp there is seperate functions.We should call that particular functions.
Then we have to move timestamp in to working storage variable.
Then we can use it for insertion. |
|
Back to top |
|
|
sbalajibe
New User
Joined: 15 Aug 2005 Posts: 62
|
|
|
|
hi ,
let us assume the u r table has three columns
age
name
timestamp
then u r code will look like
EXEC SQL
SELECT CURRENT TIMESTAMP
INTO :WS-CURR-TS
FROM SYSIBM.SYSDUMMY1 ;
END-EXEC
MOVE 20 to AGE.
MOVE 'dipanshu' TO NAME.
EXEC SQL
INSERT INTO TABLE1
VALUES
(:NAME,:AGE,:WS-CURR-TS );
END-EXEC
THANKS
BALAJI |
|
Back to top |
|
|
pa1chandak Currently Banned New User
Joined: 31 Jan 2006 Posts: 55
|
|
|
|
YOU CAN GIVE THE TIME STAMP BY JCL
ACCEPT IT
AND IN JCL GIVE TIMESTAMP VALUE IN CODES
IT WILL WORK
PAWAN C. |
|
Back to top |
|
|
babuprasad_g Currently Banned New User
Joined: 26 May 2005 Posts: 45 Location: gurgaon
|
|
|
|
Hi,
If we give timestamp in JCL.we wont get exact timestamp.
Am i right. Correct me if any error. |
|
Back to top |
|
|
|