Re: pg_atoi error - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: pg_atoi error
Date
Msg-id 20040123151215.GA13726@wolff.to
Whole thread Raw
In response to pg_atoi error  (LIANHE SHAO <lshao2@jhmi.edu>)
List pgsql-novice
On Fri, Jan 23, 2004 at 15:01:15 +0000,
  LIANHE SHAO <lshao2@jhmi.edu> wrote:
> Hello,
>
> In my query:
> select * from experimentinfo where expid='1';
> here data type of expid is int.
> My question is:
> if I change expid ='xyz', error is: pg_atoi: error
> in "xyz": can't parse "xyz"
> if I change expid ='', error is: pg_atoi:
> zero-length string
>
> In mysql, seems this will not happen and will give
> you 0 row result. but not error message.

If you want to shoot yourself in the foot go use mysql.

>
> So, How can I avoid these annoying message?

You can either have your application handle obviously bogus data or
you can write a function in postgres that converts text to int using
whatever rules you want for assigning values to nonnumeric strings.

pgsql-novice by date:

Previous
From: LIANHE SHAO
Date:
Subject: pg_atoi error
Next
From: Tom Lane
Date:
Subject: Re: Problem with initdb. Locale?