![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am trying to add entries to my database via a Perl script, where some fields are optional, that is, nulls are allowed. When inserting an entry, I include every field in the insert statement, but leave their value undefined if it is optional and left blank. This works for every field but date fields. Setting a date field to undefined generates the error "Bad date external representation". Is there a way to leave a date field null while still having it as an argument in an insert (i.e. INSET INTO table (id, mydate) VALUES (1, NULL) ), or will I need to make several different insertion statements for each different case? |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
error "Bad date external representation". Is there a way to leave a date field null while still having it as an argument in an insert (i.e. INSET INTO table (id, mydate) VALUES (1, NULL) ), or will I need to make several different insertion statements for each different case? |
#5
| |||
| |||
|
|
Rob, I checked on your problem; DBD::Pg correctly interprets undef as NULL, and PostgreSQL will accept a NULL in any NULLable date column. So there's something else going on in your program. Or you're using the wrong/really old DBI driver. |
#6
| |||
| |||
|
|
That may be the problem. I'm using debian-sparc, and I recently had a problem were it kicked me back to an older version of pgperl. I may have to investigate this on the debian mailing list. |
![]() |
| Thread Tools | |
| Display Modes | |
| |