X-Original-To: pgsql-sql@postgresql.org Received: from localhost (unknown [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 7E411924D07 for ; Fri, 23 May 2003 05:49:43 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 88932-03 for ; Fri, 23 May 2003 05:49:11 -0400 (EDT) Received: from neptune.adelis.net (neptune.adelis.net [195.115.171.102]) by developer.postgresql.org (Postfix) with ESMTP id 69087925B40 for ; Fri, 23 May 2003 03:38:36 -0400 (EDT) Received: from adelis.com (ben.adelis.net [195.115.171.16]) by neptune.adelis.net (Postfix) with ESMTP id 390D079226 for ; Fri, 23 May 2003 09:31:21 +0200 (CEST) Message-ID: <3ECDCFFB.1090808@adelis.com> Date: Fri, 23 May 2003 09:38:35 +0200 From: =?ISO-8859-1?Q?Beno=EEt_Bournon?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.2.1) Gecko/20030225 X-Accept-Language: fr, en-us, en, ja MIME-Version: 1.0 Cc: pgsql-sql@postgresql.org Subject: Re: tablename as attribute in pgplsql References: <20030522184108.C51260-100000@megazone23.bigpanda.com> In-Reply-To: <20030522184108.C51260-100000@megazone23.bigpanda.com> Content-Type: multipart/alternative; boundary="------------050709000603020204000103" X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/482 X-Sequence-Number: 13647 --------------050709000603020204000103 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit It is not possible tu use a specific argument ? type table or tablename ? execute is not runnig Stephan Szabo a écrit: >On Thu, 22 May 2003, [ISO-8859-1] Beno?t Bournon wrote: > > > >>DECLARE >> usertablename ALIAS FOR $1 ; >> userid ALIAS FOR $2 ; >> >> id_lang BIGINT ; >> >> var VARCHAR(200) ; >> >>BEGIN >> var := 'client' ; >> >> SELECT id_language INTO id_lang FROM client WHERE id_user = userid ; >> IF NOT (id_lang = 1 OR id_lang = 3) THEN >> id_lang = 1 ; >> END IF ; >> >> RETURN id_lang ; >> >>END ; >> >>I want to use client table as a variable >> >>How could I do >> >> > >Look at the documentation for EXECUTE. Unfortunately using EXECUTE into a >variable is a little complicated right now AFAIR because you can't using >select ... INTO variable inside the execute, but instead need to use >something like for in execute loop. > > > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > >http://www.postgresql.org/docs/faqs/FAQ.html > > > --------------050709000603020204000103 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit It is not possible tu use a specific argument ? type table or tablename ?

execute is not runnig

Stephan Szabo a écrit:
On Thu, 22 May 2003, [ISO-8859-1] Beno?t Bournon wrote:

  
DECLARE
   usertablename ALIAS FOR $1 ;
   userid ALIAS FOR $2 ;

   id_lang BIGINT ;

   var VARCHAR(200) ;

BEGIN
      var := 'client' ;

      SELECT id_language INTO id_lang FROM client WHERE id_user = userid ;
      IF NOT (id_lang = 1 OR id_lang = 3) THEN
          id_lang = 1 ;
      END IF ;

      RETURN id_lang ;

END ;

I want to use client table as a variable

How could I do
    

Look at the documentation for EXECUTE.  Unfortunately using EXECUTE into a
variable is a little complicated right now AFAIR because you can't using
select ... INTO variable inside the execute, but instead need to use
something like for in execute loop.



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

  
--------------050709000603020204000103--