Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us