Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: OCI Insert - Date Field Problem

Re: OCI Insert - Date Field Problem

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sat, 23 May 1998 12:37:04 GMT
Message-ID: <3567c2bc.1353706@192.86.155.100>


A copy of this was sent to Stan Newby <siclaro_at_dfw.net> (if that email address didn't require changing) On Fri, 22 May 1998 20:34:15 -0500, you wrote:

>Hi:
>
>I'm writing a C program using OCI to update data in Oracle 7.3.
>I'm attempting to insert a row with a date field. I am using
>obndrn to bind a null terminated string containing the date
>before the oexec. The problem is that the date I'm trying to
>insert is in the format ' 'MM/DD/YYYY HH24:MI:SS' and our instance
>default is something like DD-MON-YY, so I get a "ORA-1483 error -
>not a valid month". If I change the date I'm inserting to the
>DD-MON-YY default format the insert works, but is not what I want
>because I loose the time components. I can't get our DBAs to change
>the default format neither.
>
>Is there some way I can use the TO_DATE function to get around this
>problem?
>If so, how would I use it? During the bind? (i.e. If :3 was the date
>field

not during the bind, but in the sqlstmt.

>then ..."insert into table values (:1, :2, TO_DATE(:3,'DateMask')) ").
>

thats the way to do it. build the sqlstmt with the correct format mask, parse that statement, and bind the string with the date and the to_date() will convert it for you.

>Any suggestions are appreciated.
>
>Stan Newby
>EDS-TESCA
>siclaro _at_ dfw _dot_ net
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Sat May 23 1998 - 07:37:04 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US