Search Postgresql Archives

Re: Stored Procedure table/column args

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

 



On Mon, 2013-09-02 at 18:20 -0700, Adrian Klaver wrote:
> On 09/02/2013 06:06 PM, Bret Stern wrote:
> > 'psuedo
> >
> > Can you create stored procedures that are built from parameters as
> > below, or does this defeat the pre-compiled purpose of an SP?
> >
> > create function item_exists (tbl character varying, col character
> > varying, col_val character varying)
> >
> > DECLARE
> >   x integer;
> >
> > PERFORM col FROM tbl
> >         WHERE col="'" + col_val + "'"
> > 	IF FOUND THEN
> > 	 x := 1;
> > 	else
> > 	 x := 0;
> > 	end if;
> >
> > RETURN x;
> > 	
> > ....
> >
> > left out some syntax, but should deliver the idea
> >
> > trying to build build a generic "check for existing", that's not
> > specific to a specific table/column without returning recordset
> > object overhead
> >
> > any better ways
> 
> http://www.postgresql.org/docs/9.2/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

It's all there. Regards. B stern
> 
> > thanks
> >
> >
> >
> 
> 




-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[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