MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Timestamp in Oracle D/B

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
David rae
Beginner


Joined: 02 Feb 2003
Posts: 3
Topics: 1

PostPosted: Sun Feb 02, 2003 5:23 pm    Post subject: Timestamp in Oracle D/B Reply with quote

Good Morning All,
We have a requirement to generate a timestamp field on on oracle 8 data base. As there is no timestamp data type available, I was wondering what other people use in this situation.

All suggestions gratefully accepted.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Sun Feb 02, 2003 6:22 pm    Post subject: Reply with quote

David,

I learnt Oracle longtime back before I got into mainframes.so my knowledge in oracle little rusty.I am assuming that you want the timestamp to be in DB2 format which is 26 bytes in length of format(YYYY-MM-DD.HH:MI:SS:000000).If you are just interested in the date and time format then you check the DATE datatype, which stores date *and* time.But if you also want the fractional part of a second,then the easiest way in 8i to generate a correct TIMESTAMP with fractional seconds is thru java.sql.Timestamp. The reason to use java to generate a fractional second TIMESTAMP is because Oracle has provided JVM in the database and someone already has done the work.

The datatype TIMESTAMP is introduced in oracle version 9 onwards.

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
David rae
Beginner


Joined: 02 Feb 2003
Posts: 3
Topics: 1

PostPosted: Sun Feb 02, 2003 6:38 pm    Post subject: Reply with quote

Thanks for the info. Unfortunately we are still using Oracle 8 and I dont have access to the native TIMESTAMP data type. I dont think the boss will agree to upgragde to Oracle 9 using this a s a justification.

I have see references to the user of the java interface.

Do you have sone sample code snippets of both the cobol and java side.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Sun Feb 02, 2003 8:35 pm    Post subject: Reply with quote

David,

The following is the java example for timestamp.

Code:

import java.sql.Timestamp;

public class Test {
   
   public static void main(String args[]) {
      String s = Test.getTimestamp().toString();
      System.out.println("String Value:"+s);
   }
   
   public static java.sql.Timestamp getTimestamp() {
      return new java.sql.Timestamp(System.currentTimeMillis());
   }

}



If your COBOL program is compiled as COBOL/370, COBOL for MVS & VM, or COBOL for OS/390 & VM, then you can use Language Environment Callable Services like CEELOCT--Get Current Local Date or Time in in the form YYYYMMDDHHMISS999

Or a simple way in Db2 would be

Code:

EXEC SQL     
     SET :WS-TIMESTAMP = CURRENT TIMESTAMP
END-EXEC


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
David rae
Beginner


Joined: 02 Feb 2003
Posts: 3
Topics: 1

PostPosted: Sun Feb 02, 2003 9:05 pm    Post subject: Reply with quote

Thanks for the Java code.

Unfortunately, we are not using DB2 but have ORacle 8 (which does not have TIMESTAMP as a data type).

I will give the Java a try

Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group