Re: pg_atoi error

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

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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-01-23 15:27:21 Re: Problem with initdb. Locale?
Previous Message LIANHE SHAO 2004-01-23 15:01:15 pg_atoi error