Skip site navigation (1) Skip section navigation (2)

Re: Invalid syntax for integer

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Rehan Saleem'" <pk_rehan(at)yahoo(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Invalid syntax for integer
Date: 2012-03-13 18:34:57
Message-ID: 00bb01cd0148$011419a0$033c4ce0$@yahoo.com (view raw or flat)
Thread:
Lists: pgsql-sql
>>>>>>>>  From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Rehan Saleem
Sent: Tuesday, March 13, 2012 2:26 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] Invalid syntax for integer

hi ,

what is wrong with this if statement in this function

if distance ='' THEN
    distance := 1;
    end if;
here distance variable is of type integer , this function has been created
successfully but when i execute this function it gives me this error ,

ERROR:  invalid input syntax for integer: ""
LINE 1: SELECT distance =''
                                ^
QUERY:  SELECT distance =''
CONTEXT:  PL/pgSQL function "getsitesbytfid" line 6 at IF

********** Error **********

ERROR: invalid input syntax for integer: ""
SQL state: 22P02
Context: PL/pgSQL function "getsitesbytfid" line 6 at IF

========================================================================

The empty-string is not a valid syntax for an integer.  

You probably want:  “IF (distance IS NULL) …”.

David J.


In response to

pgsql-sql by date

Next:From: David JohnstonDate: 2012-03-14 12:30:25
Subject: Re: help on a function with exception
Previous:From: M. D.Date: 2012-03-13 18:29:10
Subject: help on a function with exception

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group