Re: pg_atoi error - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: pg_atoi error
Date
Msg-id 20040123175705.GA24571@wolff.to
Whole thread Raw
In response to Re: pg_atoi error  (LIANHE SHAO <lshao2@jhmi.edu>)
List pgsql-novice
On Fri, Jan 23, 2004 at 17:34:39 +0000,
  LIANHE SHAO <lshao2@jhmi.edu> wrote:
>
> Seems you missed my point.
> Actually I am wondering if pgsql can work on its own
> with garbage data like mysql. for example if it
> should be expid ='1' but I use it with expid='xyz'.
> In this case, MySql will seliently give you 0 row
> instead of error message. From your point, Seems
> Pgsql will only give error message unless you deal
> with it manually.

Why do you think Postgres should magically pick 0 out of all of the
possible numbers to use?

If you want garbage to be treated as 0 you can write a function to
do it. If you use this function to create a cast from text to int
this might even work without you having to call the function around
the questionable data. I am not absolutely sure that unknown will
go to int through text in preference to directly to int though.
If in the real case your data isn't qouted strings but text data
already in a table, then it should work.

pgsql-novice by date:

Previous
From: LIANHE SHAO
Date:
Subject: Re: pg_atoi error
Next
From: Tom Lane
Date:
Subject: Re: pg_atoi error