Re: Calling plSQL functions - Mailing list pgsql-sql

From Tom Lane
Subject Re: Calling plSQL functions
Date
Msg-id 5177.987186949@sss.pgh.pa.us
Whole thread Raw
In response to Re: Calling plSQL functions  (Lonnie Cumberland <lonnie_cumberland@yahoo.com>)
Responses Re: Calling plSQL functions
List pgsql-sql
Lonnie Cumberland <lonnie_cumberland@yahoo.com> writes:
> I have then created a PL/pgSQL function called "register_user()" in a file
> called register.sql

> create function register_user(text,text,text,text,text,text,text,text,text)
> [snip] 
> begin
>     -- Look to see if the login is already taken
>     select * from user_info where login = client_login;

> ERROR:  unexpected SELECT query in exec_stmt_execsql()

The error message isn't very helpful, but the issue here is that you're
doing a completely useless SELECT --- or at least plpgsql thinks it's
useless, because you're discarding the result.  (I think that plpgsql is
being overly anal-retentive about it, since such a query might indeed be
useful if you then examine FOUND or ROW_COUNT, but that's the issue at
the moment.)  Try making it a SELECT INTO instead.
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: RE: RE: Re: select substr???
Next
From: Lonnie Cumberland
Date:
Subject: Re: Calling plSQL functions