Link to home
Start Free TrialLog in
Avatar of fm134
fm134

asked on

insert date to database

how to write a gava code that insert a system date into oracle daatbase
this is my database table:
CREATE DIMENSION times_dim
   LEVEL day         IS TIMES.TIME_ID
   LEVEL month       IS TIMES.CALENDAR_MONTH_DESC
   LEVEL quarter     IS TIMES.CALENDAR_QUARTER_DESC
   LEVEL year        IS TIMES.CALENDAR_YEAR
   LEVEL fis_week    IS TIMES.WEEK_ENDING_DAY
   LEVEL fis_month   IS TIMES.FISCAL_MONTH_DESC
   LEVEL fis_quarter IS TIMES.FISCAL_QUARTER_DESC
   LEVEL fis_year    IS TIMES.FISCAL_YEAR
   HIERARCHY cal_rollup    (
             day     CHILD OF
             month   CHILD OF
             quarter CHILD OF
             year
   )
   HIERARCHY fis_rollup    (
             day         CHILD OF
             fis_week    CHILD OF
             fis_month   CHILD OF
             fis_quarter CHILD OF
             fis_year
   );
Avatar of Peter Kwan
Peter Kwan
Flag of Hong Kong image

If you are using a prepared statement, you may do this:

For Oracle8i or below:
java.sql.Date d = new java.sql.Date();
d.setTime((new java.util.Date()).getTime());
stmt.setDate(x, d);

For Oracle9i or above:
java.sql.Timestamp t = new java.sql.Timestamp((new java.util.Date()).getTime());
stmt.setTimestamp(x, t);
ASKER CERTIFIED SOLUTION
Avatar of Peter Kwan
Peter Kwan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fm134
fm134

ASKER

I am using oracle 10g
So you can use the Timestamp one
Avatar of fm134

ASKER

hi pkwan
thanks alot for helping me but can u please showme excactly who ti insert it to the database in java. becuase this  isthe first time I deal withe dimentions
Avatar of fm134

ASKER

hi pkwan
thanks alot for helping me but can u please showme excactly who ti insert it to the database in java. becuase this  isthe first time I deal withe dimentions