Setting a Column to Null

A column can easily be set to null when an SQL statement is used directly to update a table:

UPDATE TESTCURSOR SET RECVAL = NULL WHERE RECNO = 1;

It's different when a prepared statement is used to update records because the value will be a parameter marker:

UPDATE TESTCURSOR SET RECVAL = ? WHERE CURRENT OF cursorname;

A null pointer does not have the same meaning in SQL as it might in Java. To set a value to null, the setNull() or updateNull() methods must be used. The updateNull() method is used with result sets and is the simpler of the two methods because it only needs the index of the column. The setNull() method requires the parameter marker number and the data type of the value that the null value is supposed ...

Get Apache Derby—Off to the Races: Includes Details of IBM® Cloudscape™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.