Re: EXECUTE command in stored procedure

Поиск
Список
Период
Сортировка
От Guy Rouillier
Тема Re: EXECUTE command in stored procedure
Дата
Msg-id D4D1632DC736E74AB95FE78CD609007923B134@mtxexch01.add0.masergy.com
обсуждение исходный текст
Ответ на EXECUTE command in stored procedure  ("Arunagiri K" <arungi.pgsql@gmail.com>)
Список pgsql-general
Arunagiri K wrote:
> Dear All,
>
> How can I use EXCEUTE command in stored procedures?
> When using like this
>
> EXECUTE 'SELECT INTO REGNO REG_NO FROM ADMISSION WHERE SNAME = ' ||
> STUDNAME ;
>
> STUDNAME is a local variable;
>
> I am getting error like this
>
> ERROR:  syntax error at or near "INTO" at character 8
>
> How can I solve this.

You don't mention which version of PostgreSQL you are using, or which
stored procedure language.  I'll assume 8.1.x and PL/pgSQL.  See section
36.6 in the documentation.  Specifically, 36.6.5 says:

"SELECT INTO is not currently supported within EXECUTE."

However, if I'm understanding what you are trying to do, you shouldn't
need the EXECUTE at all.  Doing a simple SELECT INTO should work for
you.  Note also that since you are only retrieving a single value, you
can also avoid INTO altogether with something like:

REGNO := (select regno from admission where sname = myname);

--
Guy Rouillier

В списке pgsql-general по дате отправления:

Предыдущее
От: Ron Johnson
Дата:
Сообщение: Re: How to force the parser to use index scan instead of
Следующее
От: "stevegy"
Дата:
Сообщение: Re: Hi, For the UTF-8 encoding