Inserting date type to Oracle

Hello everyone!

I’m trying to insert a date value in Oracle to no avail, here’s an example of what I do:

  • fsDoc is a foundset of table Document. Column dateDoc is type dateTime and is part of the primary key of table Document.
  • pDate is a string variable containing a value in format “yyyyMMdd”.
var record = fsDoc.newRecord();
record.idDoc = 6;
record.dateDoc = utils.dateFormat(pDate, "yyyyMMdd");
record.totalvalue =  100.22;
databaseManager.saveData(record);

On saveData I’m getting the following: ORA-01400 Cannot insert null into (myDatabase.Document.dateDoc)

I also tried using string data type with the following:

utils.dateFormat(utils.dateFormat(pDate, "yyyyMMdd"), "dd/MM/yyyy");

utils.dateFormat(utils.dateFormat(pDate, "yyyyMMdd"), "MM/dd/yyyy");

And get the same error. I also tried not programatically setting a value for dateDoc and setting an Auto Enter system value for the column withing Servoy… but still get the same thing.

First I thought it was an issue of date format and Ive extensively browsed online documentation and the forum looking for something similiar… but now I just don’t know. Any thoughts?

Regards,
jd2p

jd2p,

I just tried a small test and it worked as expected.

Are you sure the pDate variable is a string and formatted correctly?

Rob

Hi Rob,

Thanks for the answer. I reviewed the code and found my childish mistake since variable record wasn’t referencing the newly created record, I changed:

var record = fsDoc.newRecord();

to:

var record = fsDoc.getRecord(fsDoc.newRecord());

that did it.

Regards,
JD