Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: OCI (how to insert a date)
to_date takes two arguments (refer to the sql reference manual) not one. You are providing two arguments in one single string to one bind variable. Your date mask isn't used at all, which is why you are getting the error.
Hth,
Sybrand Bakker, Oracle DBA
"Ajay K. Agrawal" <ajaykagrawal_at_hotmail.com> wrote in message
news:kkRu6.2867$Vj1.22459_at_open-news.pacbell.net...
> Hi!
>
> I need help on how to pass a string value to a date column using OCI. For
> testing purposes I have created a simple table ("AKADATE") which only has
> one column of type DATE.
>
> I now want to insert a row. This is what I do:
>
> Prepare a statement.
> --------------------
> The query is:
>
> INSERT into AKADATE values (TO_DATE(:1))
>
> Bind the statement by position.
> -------------------------------
> Here are some arguments:
>
> position - 1 (first column)
> valuep - pointer to a null-terminated string.
> value_sz - 64 (should be big enough)
> dty - SQLT_STR
>
> Execute tne statement
> ----------------------
> If I pass "02-FEB-1997" for valuep, then the execution succeeds. However
if
> I pass any
> other value such as: "'Feb-11-2001','MON-DD-YYYY'" then the execution
fails.
> I have tried
> different combinations such as
>
> "Feb-11-2001,MON-DD-YYYY" (no single quotation marks)
> "Feb-11-2001 , MON-DD-YYYY" (space between comma)
> "Feb-11-2001 ,'MON-DD-YYYY'" (only single quotation marks for the format)
> ...
>
> but nothing seems to work! In all cases I get this error:
>
> ORA-01858: a non-numeric character was found where a numeric was expected
>
> I am sure it is something simple but since this is my first venture into
OCI
> I am stumped!
>
> Any help will be greatly appreciated!!
>
> Thanks!
>
> -Ajay Agrawal
>
> ajay_at_themoment.com
>
>
>
>
Received on Sat Mar 24 2001 - 01:30:03 CST
![]() |
![]() |