Search Postgresql Archives

Re: EXECUTE command in stored procedure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux