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

Home -> Community -> Usenet -> c.d.o.server -> I need help using DATE functions in an INSERT in embedded SQL with C

I need help using DATE functions in an INSERT in embedded SQL with C

From: Tony <ramdan_at_sprintmail.com>
Date: 1997/08/30
Message-ID: <5u97oo$h1o$1@newsfep1.sprintmail.com>#1/1

I am reading a file that has a field with date data of the form '08011997'. And I also need to have the current date inserted.  The Oracle table has date columns of 10 bytes each.

My SQL statement looks like the following. I am using host variables defined as following ( int id_num, char in_date [10], char to_day [10], double cost)

I get the sysdate as follows:

EXEC SQL to_char(sysdate, 'mmddyyyy') INTO :to_day FROM dual;

The statement is :

EXEC SQL INSERT (idnumber, enterdate, todaydate, cost)         

VALUES (:id_num, :in_date, :to_day, :cost);

however, when I run program it gives me the following error:

ORACLE ERROR : INCORRECT MONTH - on the in_date (08011997) ORACLE ERROR: INCOMING STREAM IS TRUNCATED BEFORE END OF CONVERSION

I have tired every combination of mmddyyyy but still get the same problem. The table column has a 10 byte size, yet when I do a dynamic select I see the following 29-AUG-1997 08:13:21 as the result it gives back. In dynamic SQL I have used the following
INSERT (idnumber, incomingdate, todaydate, cost) VALUES (12334, '08011997', sysdate, cost);

It takes sysdate but gives me invalid month on first one (i also tried with quotes and no quotes).

How do I get the date in in a way it will accept!!! I have checked every manual out there. Oracle's docu and looked at various books, yet no solution.

Please respond in newsgroup or at ramdan_at_mailexcite.com

Thank you Received on Sat Aug 30 1997 - 00:00:00 CDT

Original text of this message

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