oracle::occi::Date.SetDate() is crashing : (exception) Error=32146 : ORA-32146: Cannot perform operation on a null date

43 views Asked by At

I having the next simple code that get exception "32146 Cannot perform operation on a null date"

oracle::occi::Date dt;
dt.setDate(tt.tm_year, tt.tm_mon, tt.tm_mday, tt.tm_hour, tt.tm_min, tt.tm_sec);

The tt.tm_year, tt.tm_mon, tt.tm_mday, tt.tm_hour, tt.tm_min, tt.tm_sec values are:

tm_year=114, tt.tm_mon=1, tt.tm_mday=4, tt.tm_hour=1, tt.tm_min=2, tt.tm_sec=0

WHY do I get exception? Thanks

2

There are 2 answers

1
MT0 On

You have not explicitly initialised the dt variable so it is using the default class constructor and is NULL.

Summarising the C++ Call Interface Programmer's Guide (with your variables), you need to use the class constructor to initialise it to a non-NULL value:

Environment *env = Environment::createEnvironment(Environment::DEFAULT);
Date dt(env, tt.tm_year, tt.tm_mon, tt.tm_mday, tt.tm_hour, tt.tm_min, tt.tm_sec);
0
Arnon On

Need to init with environment. However, not clear why it is crashing. Not using any connectivity to the DB. Only populate the Date object to send it later to the DB as parameter to the query