Re: pg_atoi error

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: LIANHE SHAO <lshao2(at)jhmi(dot)edu>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: pg_atoi error
Date: 2004-01-23 17:57:05
Message-ID: 20040123175705.GA24571@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, Jan 23, 2004 at 17:34:39 +0000,
LIANHE SHAO <lshao2(at)jhmi(dot)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.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-01-23 17:59:15 Re: pg_atoi error
Previous Message LIANHE SHAO 2004-01-23 17:34:39 Re: pg_atoi error