Home » Developer & Programmer » Precompilers, OCI & OCCI » Indicator Values for DATES (Oracle 10g2, Solaris)
Indicator Values for DATES [message #458706] Tue, 01 June 2010 07:08 Go to next message
mjm22
Messages: 54
Registered: January 2010
Location: Singapore
Member
Hi,

If doing an insert into DATE type fields like below... how do I employ null indicator values with the TO_DATE sql to cope with NULL values for the End Date?
I can test the NULLness of the pServiceRecord->itemTo value and set the indicator ind_dbToDate to -1 but I don't know how to incorporate this with the to_date syntax (if I can)?

EXEC SQL BEGIN DECLARE SECTION;
    char    dbFromDate[MAX_DATE_LEN];
    char    dbToDate[MAX_DATE_LEN];

    short   ind_dbToDate;

    EXEC SQL VAR dbFromDate IS STRING;
    EXEC SQL VAR dbToDate IS STRING;
EXEC SQL END DECLARE SECTION;

sprintf(dbFromDate,"%s",pServiceRecord->itemFrom);
sprintf(dbToDate,"%s",pServiceRecord->itemTo);

EXEC SQL
insert into MYDATES (from_date, to_date)
             values (TO_DATE(:dbFromDate,:dbOraDateFmt),
                     TO_DATE(:dbToDate,:dbOraDateFmt));

Re: Indicator Values for DATES [message #458717 is a reply to message #458706] Tue, 01 June 2010 07:39 Go to previous messageGo to next message
Michel Cadot
Messages: 68045
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
TO_DATE(:dbFromDate:ind_dbToDate,:dbOraDateFmt)
or
TO_DATE(:dbFromDate INDICATOR :ind_dbToDate,:dbOraDateFmt)

Regards
Michel

[Updated on: Tue, 01 June 2010 07:39]

Report message to a moderator

Re: Indicator Values for DATES [message #461033 is a reply to message #458717] Wed, 16 June 2010 04:03 Go to previous message
mjm22
Messages: 54
Registered: January 2010
Location: Singapore
Member

Ok, Thanks Michel.
Previous Topic: how to commit and rollback in external "C" procedure
Next Topic: 11g pro*c appliation crashes while 10g is ok, why?
Goto Forum:
  


Current Time: Sat Dec 04 05:19:00 CST 2021