Re: Argument variables for select - Mailing list pgsql-sql

From Yury Don
Subject Re: Argument variables for select
Date
Msg-id 39AA2F1C.2CCE9860@vpcit.ru
Whole thread Raw
In response to Argument variables for select  (Andreas Tille <tillea@rki.de>)
Responses Re: Argument variables for select
Re: Argument variables for select
List pgsql-sql
Andreas Tille wrote:
> 
> Hello,
> 
> I want to use the following construct in a stored function:
> 
> Create Function VarSelect ( varchar, varchar )
>    returns int
>    As '
>      Declare num int ;
> 
>      Begin
>        Select Into num Count(*) From $1 Where $2 ;
>        return num;
>      End ;
>    ' language 'plpgsql' ;
> 
> Could someone please explain who to type the exact syntax so that
> I can ship the table to select from as $1 and the condition to select
> what as $2?  Or do I have to concatenate a string with the whole
> select statement and how to call this string?  In MS SQL server this
> could be done with
>    Exec ( query )
> 
> Kind regards
> 
>           Andreas.

AFAIK it's impossible with plpgsql, but it's possible in pltcl.

-- 
Sincerely yours,
Yury


pgsql-sql by date:

Previous
From: pierre@kahuna.versions.com
Date:
Subject: shared memory leak in 7.0.2?
Next
From: Andreas Tille
Date:
Subject: Re: Argument variables for select