Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D7E254765E5 for ; Tue, 1 Oct 2002 13:37:10 -0400 (EDT) Received: from marsha.pcisys.net (marsha.pcisys.net [216.229.32.146]) by postgresql.org (Postfix) with ESMTP id 60CFA4763DE for ; Tue, 1 Oct 2002 13:37:06 -0400 (EDT) Received: from [208.202.106.238] (moe1.meg106-238.cos.pcisys.net [208.202.106.238]) by marsha.pcisys.net (8.12.5/8.12.5) with ESMTP id g91Hb46u024607 for ; Tue, 1 Oct 2002 11:37:04 -0600 (MDT) User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.4 Date: Tue, 01 Oct 2002 11:37:04 -0600 Subject: Re: Inserting Null Value or String Value From: Keary Suska To: Postgres-PHP Message-ID: In-Reply-To: <20021001165453.882.qmail@web14410.mail.yahoo.com> Mime-version: 1.0 Content-type: multipart/alternative; boundary="MS_Mac_OE_3116317025_10963218_MIME_Part" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/2 X-Sequence-Number: 1517 > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --MS_Mac_OE_3116317025_10963218_MIME_Part Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit on 10/1/02 10:54 AM, dcmkx10@yahoo.com 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 ELSE " 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" --MS_Mac_OE_3116317025_10963218_MIME_Part Content-type: text/html; charset="US-ASCII" Content-transfer-encoding: quoted-printable Re: [PHP] Inserting Null Value or String Value on 10/1/02 10:54 AM, dcmkx10@yahoo.com purportedly said:

I am trying to insert a date into a date field, but also someti= mes 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 &q= uot;spec_start_date" is of type 'date' but expression is of type 'inte= ger' You will need to rewrite or cast the expression

The value I am sending is: spec_start_date =3D 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 &qu= ot;IF <use quotes> ELSE <don't use quotes>" in the SQL str= ing, by I am entering many values and this would really get messy. I was ho= ping 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"
--MS_Mac_OE_3116317025_10963218_MIME_Part--