SQL state: 22P02

From: Franklin Haut <franklin(dot)haut(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: SQL state: 22P02
Date: 2007-11-22 16:24:36
Message-ID: 4745AD44.1@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<small><font face="Courier New">Hi,<br>
<br>
I got the message "SQL state: 22P02" <br>
<br>
<br>
<br>
<b>to produce:</b><br>
<br>
create table test (num varchar(20));<br>
<br>
insert into test (num) values (null);<br>
select * from test where cast(num as int8) = 0;&nbsp;&nbsp; --ok, no error<br>
insert into test (num) values ('123123');<br>
select * from test where cast(num as int8) = 123123;&nbsp;&nbsp; --ok, no error<br>
<br>
insert into test (num) values ('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ');<br>
select * from test where cast(num as int8) = 123123;&nbsp; -- error<br>
select * from test where case when trim(num) &lt;&gt; '' then cast(num
as int8) = 123123 else false end; -- ok, changed query and no error<br>
<br>
insert into test (num) values ('a');<br>
select * from test where cast(num as int8) = 123123;&nbsp; -- error<br>
select * from test where case when trim(num) &lt;&gt; '' then cast(num
as int8) = 123123 else false end;&nbsp; -- error<br>
<br>
I need get all tuples was the table have converting the characters to
number. If one conversion fail there not displayed. <br>
<br>
<b>Ex:</b><br>
&nbsp; num&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return<br>
&nbsp; ----&nbsp;&nbsp;&nbsp;&nbsp; ------<br>
&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>
&nbsp; null &nbsp; &nbsp;&nbsp; false<br>
&nbsp; 12 &nbsp; &nbsp; &nbsp;&nbsp; 12<br>
&nbsp; a &nbsp; &nbsp; &nbsp; &nbsp; false<br>
&nbsp; 12ab&nbsp; &nbsp; &nbsp; false<br>
</font></small><font face="Courier New"><small><br>
it&acute;s possible get these results ?<br>
<br>
<br>
other question:<br>
<br>
Why this message ("</small></font><small><font face="Courier New">SQL
state: 22P02</font></small><font face="Courier New"><small>") is not
displayed with the SQL command on log in data/pg_log ?<br>
only appears&nbsp;&nbsp;&nbsp;&nbsp; <br>
<br>
2007-11-22 12:55:13 BRT ERROR:&nbsp; invalid input syntax for integer: "a"<br>
<br>
<br>
thanks,<br>
<br>
Franklin Haut<br>
<br>
<br>
<br>
<br>
<br>
</small></font>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 2.2 KB

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Martin Marques 2007-11-22 21:36:59 Re: PL argument max size, and doubt
Previous Message Rodrigo De León 2007-11-22 16:06:25 Re: SQL state: 22P02