Stefan Finzel wrote:

Within sqlite console there is a a command

.nullvalue NULL

All I want is to know how I can set and use this mechanismen from my Tcl interpreter too.

The shell can do this because it is implemented in C, which can distinguish between the NULL and empty string return values (sqlite returns either a null pointer (i.e. 0) or a pointer to an empty string). TCL does not allow this distinction to be made, so you can' t do it in TCL.


If you want to have a specific string returned to TCL if the value is NULL, you could use the COALESCE function in your SQL statements. It will return the first non-NULL argument. If you replace SQL like this

SELECT field FROM some_table

with

SELECT COALESCE(field, 'My Null String') FROM some_table

Then TCL will get the string "My Null String" for each value of field that is NULL.

This may not be a practical solution, depending upon the number o SQL statements you need to modify.

HTH
Dennis Cote



Reply via email to