View previous topic :: View next topic |
Author |
Message |
David rae Beginner
Joined: 02 Feb 2003 Posts: 3 Topics: 1
|
Posted: Sun Feb 02, 2003 5:23 pm Post subject: Timestamp in Oracle D/B |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Sun Feb 02, 2003 6:22 pm Post subject: |
|
|
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 |
|
|
David rae Beginner
Joined: 02 Feb 2003 Posts: 3 Topics: 1
|
Posted: Sun Feb 02, 2003 6:38 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Sun Feb 02, 2003 8:35 pm Post subject: |
|
|
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 |
|
|
David rae Beginner
Joined: 02 Feb 2003 Posts: 3 Topics: 1
|
Posted: Sun Feb 02, 2003 9:05 pm Post subject: |
|
|
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 |
|
|
|
|