I am using Firebird as database backend. I am not able to set a Field which is DATE or TIMESTAMP to null:
dim rs as recordset
dim d as new date
rs = app.GetRecord("Host", "NewDevelopmentDetail", 8, "", 1) //my self defined function used to get record
if rs <> nil then
rs.edit
rs.Field("ExpiryDate").value = nil
rs.update
msgbox "done"
end if
The record can only be updated if I set the field to a valid date, i.e. : rs.Field(“ExpiryDate”).value = d
Although the code above was presented as ‘the solution’ in this post, there are useful other things to read in it, such as ‘is the field defined as NOT NULL’ in the schema’
@Jean-Yves Pochez But I have setup a standard method that accepts a window or container as a parameter, then set all field values of a record according to corresponding fields automatically, then update the table. If I need to change to direct sql, I have to re-write that method again that causes a lot of work to do. Anything that can get around?
leave the other fields like they are, update your table with rs.update
juste after, apply an update query like I mentionned to clear the date, with the PK of the record.
My method updates the entire record with corresponding fields on the window/container, I can’t skip 1 or 2 fields, I think this is not the way I designed the method…
I do not read it, but it seems to have a pretty complete information.[/quote]
SQLite handles NULL vastly differently than other database engines, so I would not assume that if it works (or doesn’t work in SQLite) that the same applies elsewhere
I have setup a simple project, when I tried to set rs.Field(“Date”).value = nil and preform a rs.update, it returns an error: -303 conversion error from string “”
Does this mean there is a bug in Xojo ODBC plugin?