OCI (how to insert a date)

From: Ajay K. Agrawal <ajaykagrawal_at_hotmail.com>
Date: Fri, 23 Mar 2001 15:51:40 -0800
Message-ID: <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 - 00:51:40 CET

Original text of this message