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

Re: Converting a proceedure from SOLID to Postgres

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: (view raw, whole thread or download thread mbox)
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

		person int4;

          SELECT h.who INTO person
          FROM   history h, issues iss
          WHERE = int_issue_id_var
          AND = h.issue
          AND    h.h_type = 3
          AND    h.who <> iss.submitter
          ORDER BY DESC LIMIT 1;

                 person := 0;
          END IF;

          RETURN person;

but I'm just guessing...

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Jesus AneirosDate: 2001-05-05 12:28:36
Subject: Re: psql with PHP question
Previous:From: Tom LaneDate: 2001-05-04 22:39:45
Subject: Re: unique (a,b)?

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