I would like to get around this NULL issue.
Here is the SQL using PG7.1 that updates ONE record.
The record will NOT update if the field is NULL but
if I set the field to '' or 'any text here' all is well. Here is
the code:
data=# update users set admin_note = NULL where user_id=5;
UPDATE 1
data=# update users set admin_note = admin_note || '
' ||
now() || ' My note here' where user_id=5;
UPDATE 1
data=# select admin_note from users where user_id=5;
admin_note
------------
(1 row)
data=# update users set admin_note = '' where user_id=5;
UPDATE 1
data=# update users set admin_note = admin_note || '
' ||
now() || 'My note here' where user_id=5;
UPDATE 1
data=# select admin_note from users where user_id=5;
admin_note
-------------------------------------
2002-01-24 16:47:03-05 My note here
(1 row)
So, I want to use the command to add lines to the
admin_note field in many records at once like this:
update users set admin_note = admin_note || '
' ||
now() || ' My note here' where user_id > 1000;
The only records updated are those in which there
is already text in the field. All the rest of the
insert is lost if admin_note is NULL.
Is there a way to do this without making all admin_note fields
NOT NULL?
-Bob