Skip site navigation (1) Skip section navigation (2)

Argument variables for select

From: Andreas Tille <tillea(at)rki(dot)de>
To: PostgreSQL SQL <pgsql-sql(at)hub(dot)org>
Subject: Argument variables for select
Date: 2000-08-28 08:06:13
Message-ID: Pine.LNX.4.21.0008280957530.30760-100000@wr-linux02.rki.de (view raw or flat)
Thread:
Lists: pgsql-sql
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.


Responses

pgsql-sql by date

Next:From: Yury DonDate: 2000-08-28 09:21:32
Subject: Re: Argument variables for select
Previous:From: Richard RowellDate: 2000-08-28 07:56:05
Subject: Can I get this all in one query?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group