pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Bruce Young <hbrucey@yahoo.com>
Cc: PostgresPHP <pgsql-php@postgresql.org>
Subject: Re: updating integer column
Date: Mon, 24 Feb 2003 10:18:17 -0700 (MST)
Message-ID: <Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com> (raw)
In-Reply-To: <20030222160726.91848.qmail@web10410.mail.yahoo.com>

On Sat, 22 Feb 2003, Bruce Young wrote:

> hi all, i have a table with an int8 column.
> my PHP script should update a row with the new values in the form.
> it works fine if i put a number in the field but gives this error if left
> blank:
> 
> Warning: pg_exec() query failed: ERROR: Bad int8 external representation "" in
> /home/httpd/htdocs/forms/manage/update_profile.php on line 140
> 
> how can i get around this..
> oh and what is the best datatype to use for a 10 digit phone number?.

Hiya Bruce.

Yep, postgresql is doing it's job, making sure you don't stick the wrong 
data into the wrong type.  For an int, the legal values are all the 
numbers from the negative max to positive max, as well as nulls.  note 
that column constraints can limit this as well, making it positive only, 
or no nulls, or only even numbers, etc...

So, if you want to put a null in, just do that:

insert into table (id, number) values (1,NULL);

Secondly, for a phone number, ask yourself how you're going to treat it.  
Are you going to do a sum() across the numbers?  Or maybe multiply them 
together? 

If yes, then you should store them as some kind of numeric, int, or as a 
float.

If, however, the numbers are not going to be used for math but for 
identification, then it is likely that a text / varchar type would be a 
better choice.




view thread (10+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: scott.marlowe@ihs.com, hbrucey@yahoo.com
  Subject: Re: updating integer column
  In-Reply-To: <Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com>
  References: <20030222160726.91848.qmail@web10410.mail.yahoo.com> <Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox