Re: Stored Procedure table/column args - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Stored Procedure table/column args
Date
Msg-id 5225395D.10408@gmail.com
Whole thread Raw
In response to Stored Procedure table/column args  (Bret Stern <bret_stern@machinemanagement.com>)
Responses Re: Stored Procedure table/column args  (Bret Stern <bret_stern@machinemanagement.com>)
List pgsql-general
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

> thanks
>
>
>


--
Adrian Klaver
adrian.klaver@gmail.com


pgsql-general by date:

Previous
From: Bret Stern
Date:
Subject: Stored Procedure table/column args
Next
From: Bret Stern
Date:
Subject: Re: Stored Procedure table/column args