Re: Calling plSQL functions

From: Lonnie Cumberland <lonnie_cumberland(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Calling plSQL functions
Date: 2001-04-13 18:57:14
Message-ID: 20010413185714.7788.qmail@web12502.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thanks for the info Tom,

I found that same solution just after I had sent this message to the mailing
list.

I set up a RECORD variable that should receive the results, but the
documentation is unclear as to if the variable will receive ALL of the results
from the query of just the first result from the query.

Actually I have the need at different places in my functions to sometimes work
on the list items returned from a query and also have the need to just work on
the first result returned by a query.

Can you please tell me how these two can easily be done?

Cheers,
Lonnie

--- Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Lonnie Cumberland <lonnie_cumberland(at)yahoo(dot)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

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-04-13 19:02:53 Re: Calling plSQL functions
Previous Message Tom Lane 2001-04-13 18:38:48 Re: RE: RE: Re: select substr???