Insert NULL into numeric? (Interbase)

From: Date: Wed, 18 Oct 2000 13:07:46 +0000
Subject: Insert NULL into numeric? (Interbase)
Groups: php.db 
Request: Send a blank email to php-db+get-3724@lists.php.net to get a copy of this message
Greetings. From isql: create table test ( id integer, col varchar(32) ); insert into test (id, col) values ( 1, 'bob is my friend' ); update test set id = null; I want to set a numeric field to null from PHP script (ODBC interface). For strings, dates, I can do this: $var = 'null'; $sql = "update test set col = $var;" ... odbc_prepare ( $connection, $sql ); ... This sets col = NULL (as in the NULL value) For numeric fields, the above code (id column) does not work because the database will get this sql statement update test set id = 'null'; (causes string -> numeric conversion error) when it wants ( no single quotes ) update test set id = null; If I set my numeric variable to nothing : $variable = "" and then try the $sql = "update test set col = '$var'; the database gets: update test set id = ''; which results in a string -> numeric conversion error. Finally, if $var is not set at all $sql = "update test set id = $var;" : (of course does not work) update test set col = ; I don't want to set to zero, as null is the correct value (it's from a field in an HTML form). In Oracle, you can set an indicator variable on INSERT or UPDATE that tells Oracle to set the column (string or numeric) to NULL. Did not see any analagous ODBC function calls (or in the broken Interbase native PHP driver - broken on NT, not Linux). I appreciate any suggestions. Thanks Jeff -- jccann [at] home [dot] com

« previous php.db (#3724) next »