From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Bob Whitehouse" <bwhitehouse(at)geeknest(dot)com> |
Cc: | "pgsql-novice" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Converting a proceedure from SOLID to Postgres |
Date: | 2001-05-04 23:20:26 |
Message-ID: | 2682.989018426@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
"Bob Whitehouse" <bwhitehouse(at)geeknest(dot)com> writes:
> When I run this I get this error message:
> SQL: select get_last_respondent(1290)
> [Fri May 4 16:30:40 2001] null: DBD::Pg::st execute failed: ERROR:
> unexpected SELECT query in exec_stmt_execsql()
plpgsql believes (for no good reason AFAICS) that a SELECT that doesn't
put its results someplace must be a mistake. Therefore it wants you
to do SELECT INTO rather than plain SELECT. If you're only doing the
SELECT so that you can check FOUND or ROW_COUNT, you still need to
select into a dummy variable.
As near as I can tell, the function you are trying to translate also
does a SELECT INTO and returns the result of that select (if
successful). So in reality, your translation is wrong anyway.
I think you want something like
declare
person int4;
begin
SELECT h.who INTO person
FROM history h, issues iss
WHERE iss.id = int_issue_id_var
AND iss.id = h.issue
AND h.h_type = 3
AND h.who <> iss.submitter
ORDER BY h.id DESC LIMIT 1;
IF NOT FOUND THEN
person := 0;
END IF;
RETURN person;
but I'm just guessing...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jesus Aneiros | 2001-05-05 12:28:36 | Re: psql with PHP question |
Previous Message | Tom Lane | 2001-05-04 22:39:45 | Re: unique (a,b)? |