Re: Problem with TO_DATE from PRO*C (gives error 904)
Date: 14 Jan 1995 01:00:05 GMT
Message-ID: <3f77ml$4hl_at_fred.uswnvg.com>
L. Scott Johnson (sjohnson_at_math.scarolina.edu) wrote:
: jan-olav.eide_at_noner.abb.telemax.no (Jan Olav Eide) writes:
: >I seem to be unable to use the TO_DATE function to convert a string
: >value for insertion into a date field. Am I missing something
: >essential here (Version 6.0.34.2 on a VAX) ?
: >EXEC SQL BEGIN DECLARE SECTION
: >char datestr[30];
: >EXEC SQL END DECLARE SECTION
: >strcpy(datestr,"17-12-1995 13:12:21");
: >EXEC SQL UPDATE alarm_status
: > SET GMT = TO_DATE(ds,'DD-MM-YYYY HH24:MI:SS')
^^: >columns of correct types, and I can do the statement in SQL*PLUS without
: > WHERE ALARM_ID = :alarm_id;
: ^^^^^^^^^
: >This gives error code 904 Invalid column name. But GMT and ALARM_ID *are*
: >problems. I get exactly the same error if I make the column name illegal.
Is DS a column name? or should that line be:
: > SET GMT = TO_DATE(:datestr,'DD-MM-YYYY HH24:MI:SS')
: ?
: Where is :alarm_id set/declared?
: Try replacing this with a constant value for testing.
: L. Scott Johnson
I was doing a similar thing, getting the date/time string from the c function. The problem was that the c function alway returned a specific number of characters even when there was less than 2 digits for the hour. This meant that two spaces followed the year prior to the hour. This is a no-no. The TO_DATE() failed to convert the string. I eventually wrote code to remove all spaces that exceeded one space. Since then, no problems. Mike KrolewskiReceived on Sat Jan 14 1995 - 02:00:05 CET