Re: Inserting Null Value or String Value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Title: Re: [PHP] Inserting Null Value or String Value
on 10/1/02 10:54 AM, dcmkx10@xxxxxxxxx purportedly said:

I am trying to insert a date into a date field, but also sometimes I need to insert a null value.  Inserting the null value seems to require not using quotes around null, but if I try to enter a date without quotes around it, it thinks it is a number.

Here is the error I get: Warning: PostgreSQL query failed: ERROR: column "spec_start_date" is of type 'date' but _expression_ is of type 'integer' You will need to rewrite or cast the _expression_

The value I am sending is: spec_start_date = 10/01/02

If I surround the date with single quotes it should be fine, but I can't do that when I want to insert a null value.  I know that I can do an "IF <use quotes> ELSE <don't use quotes>" in the SQL string, by I am entering many values and this would really get messy. I was hoping that there was a better solution. Thanks for any help.

If there is a way, I haven't found it yet. But it doesn't have to be messy--simply create a function that does the if-else for you, and your code will stay clean.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux