Forum OpenACS Development: Response to PgBindCmd turns the empty string into NULL

Posted by Tom Jackson on

The problem can be handled in the application, so it really isn't a problem, at least for me. Here is what I did. I test the value of the attribute to see if it is equal to the empty string. If so, I don't use a bind variable, I just use ''. If you want to pass NULL to the database, you can either set the bind variable to the empty string, or just use an unquoted NULL in the pl or dml string. The only issue is having the database driver guess which is which. Note that in my application I use a passed in NULL (in the pg or oracle function) to determine if an attribute needs updating or not, so I still have to have a separate function to set attributes back to NULL.

BTW, I don't think tcl can tell the difference between NULL and '' either. Probably if you built an application in Oracle that relied on an attribute being either NULL or '', you would have a potential bug in the pg version.