Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How insert a value for a field named TIMESTAMP in DB2 table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How insert a value for a field named TIMESTAMP in DB2 table
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    Post subject: Re: cobol & db2 query
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    Post subject:
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    Post subject: Re: cobol & db2 query
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    Post subject: Re: cobol & db2 query
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: No
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us