IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How insert a value for a field named TIMESTAMP in DB2 table


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dipanshu

New User


Joined: 16 Jan 2006
Posts: 53
Location: pune

PostPosted: Sat Jan 28, 2006 4:05 pm
Reply with quote

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
View user's profile Send private message
elonics

New User


Joined: 05 Jul 2005
Posts: 49
Location: India

PostPosted: Sat Jan 28, 2006 4:29 pm
Reply with quote

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
View user's profile Send private message
dipanshu

New User


Joined: 16 Jan 2006
Posts: 53
Location: pune

PostPosted: Sat Jan 28, 2006 4:42 pm
Reply with quote

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
View user's profile Send private message
elonics

New User


Joined: 05 Jul 2005
Posts: 49
Location: India

PostPosted: Sat Jan 28, 2006 5:30 pm
Reply with quote

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
View user's profile Send private message
elonics

New User


Joined: 05 Jul 2005
Posts: 49
Location: India

PostPosted: Sat Jan 28, 2006 5:37 pm
Reply with quote

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
View user's profile Send private message
nrsmca

New User


Joined: 25 May 2005
Posts: 14

PostPosted: Tue Jan 31, 2006 4:16 pm
Reply with quote

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
View user's profile Send private message
dipanshu

New User


Joined: 16 Jan 2006
Posts: 53
Location: pune

PostPosted: Tue Jan 31, 2006 4:50 pm
Reply with quote

Hi ,

INSERT INTO TABLE1
VALUES
(:NAME,:AGE,CURRENT_TIMESTAMP);

Could anyone confirm the above query

thanks
Dipanshu
Back to top
View user's profile Send private message
babuprasad_g
Currently Banned

New User


Joined: 26 May 2005
Posts: 45
Location: gurgaon

PostPosted: Tue Jan 31, 2006 7:17 pm
Reply with quote

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
View user's profile Send private message
sbalajibe

New User


Joined: 15 Aug 2005
Posts: 62

PostPosted: Wed Feb 01, 2006 5:14 pm
Reply with quote

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
View user's profile Send private message
pa1chandak
Currently Banned

New User


Joined: 31 Jan 2006
Posts: 55

PostPosted: Wed Feb 01, 2006 5:33 pm
Reply with quote

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
View user's profile Send private message
babuprasad_g
Currently Banned

New User


Joined: 26 May 2005
Posts: 45
Location: gurgaon

PostPosted: Thu Feb 09, 2006 8:20 pm
Reply with quote

Hi,

If we give timestamp in JCL.we wont get exact timestamp.

Am i right. Correct me if any error.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top