pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Invalid syntax for integer
2+ messages / 2 participants
[nested] [flat]

* Invalid syntax for integer
@ 2012-03-13 18:25  Rehan Saleem <pk_rehan@yahoo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Rehan Saleem @ 2012-03-13 18:25 UTC (permalink / raw)
  To: pgsql-sql

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

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Invalid syntax for integer
@ 2012-03-13 18:34  David Johnston <polobo@yahoo.com>
  parent: Rehan Saleem <pk_rehan@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: David Johnston @ 2012-03-13 18:34 UTC (permalink / raw)
  To: 'Rehan Saleem' <pk_rehan@yahoo.com>; pgsql-sql

>>>>>>>>  From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Rehan Saleem
Sent: Tuesday, March 13, 2012 2:26 PM
To: pgsql-sql@postgresql.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.




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-03-13 18:34 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 18:25 Invalid syntax for integer Rehan Saleem <pk_rehan@yahoo.com>
2012-03-13 18:34 ` David Johnston <polobo@yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox