views:

1496

answers:

2

I need to insert some data into a table in Oracle.

The only problem is one of the fields is a timestamp(6) type and it is required data. I don't care about what actually goes in here I just need to get the right syntax for an entry so that the database will accept it.

I'm using the gui web client to enter data however I don't mind using raw SQL if I have to.

Thanks.

+5  A: 

I dunno if this helps at all, but in SQL*Plus I did this:

create table x ( a timestamp(6));
insert into x values ( current_timestamp );
select * from x;

getting me this:

T
---------------------------------------------------------------------------
15-OCT-08 02.01.25.604309 PM

So it looks like that works.

If you need to put a previously-known value into the column, how about the TO_TIMESTAMP() function? Something like this:

select to_timestamp('27/02/2002 15:51.12.539880', 'dd/mm/yyyy hh24:mi.ss.ff') 
from dual ;
Mike Woodhouse
the to_timestamp function didn't work for me in this particular case (the database client didn't like it) - but it seems like a good way to create timestamp values. Thanks.
Scottm
+1  A: 

using to_timestamp() is one option. the other is doing this:

INSERT INTO table VALUES (timestamp'2009-09-09 09:30:25 CET');
bene