![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
|
So, How can I avoid these annoying message? |
#3
| |||
| |||
|
|
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. The above query is simple, but my query sometimes is kind of complex. If I have to manually deal with each possible bogus data or use functions to convert each string to number, beside lot of overhead, maybe there are somethings you still forget to do. Seems it does not solve the problem completely. |
#4
| |||
| |||
|
|
Please keep threads on the mailing list. On Fri, Jan 23, 2004 at 15:32:47 +0000, LIANHE SHAO <lshao2 (AT) jhmi (DOT) edu> wrote: 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. The above query is simple, but my query sometimes is kind of complex. If I have to manually deal with each possible bogus data or use functions to convert each string to number, beside lot of overhead, maybe there are somethings you still forget to do. Seems it does not solve the problem completely. This doesn't make sense. If you want to treat all garbage data as beingthe same as 0, just write a function to do it. If you don't know what to do with the garbage data, how do you expect Postgres to do the right thing on its own. Seems you missed my point. |
#5
| |||
| |||
|
|
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. |
#6
| |||
| |||
|
|
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. |
#7
| |||
| |||
|
|
LIANHE SHAO <lshao2 (AT) jhmi (DOT) edu> writes: 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. This is a fundamental difference in philosophy between the two projects. You are wasting your breath trying to convince any Postgres developer that this aspect of MySQL's behavior is a wise design. And I'm sure you would get equally much push-back from the MySQL developers if you tried to persuade them to tighten their error checking. If MySQL's philosophy agrees with your worldview, then you should probably go use MySQL. Alternatively, you can write your own conversion function that does what you want, as several people have suggested already. You can even cause it to become the default behavior in your installation (just change the input function for type int4). But it's not going to become the standard behavior for Postgres. regards, tom lane |
![]() |
| Thread Tools | |
| Display Modes | |
| |