Received: from vpcit.ru (qmailr@dialup.vpcit.ru [195.38.52.246]) by hub.org (8.10.1/8.10.1) with SMTP id e7S9MdL18826 for ; Mon, 28 Aug 2000 05:22:41 -0400 (EDT) Received: (qmail 32661 invoked from network); 28 Aug 2000 09:22:14 -0000 Received: from nt5.vpcit.ru (HELO vpcit.ru) (195.38.52.238) by dialup.vpcit.ru with SMTP; 28 Aug 2000 09:22:14 -0000 Message-ID: <39AA2F1C.2CCE9860@vpcit.ru> Date: Mon, 28 Aug 2000 15:21:32 +0600 From: Yury Don Organization: gercon X-Mailer: Mozilla 4.74 [en] (X11; U; Linux 2.2.15 i686) X-Accept-Language: ru, en MIME-Version: 1.0 To: pgsql-sql@hub.org Subject: Re: Argument variables for select References: Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-Archive-Number: 200008/303 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