X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E1F23D1D749; Wed, 12 May 2004 07:13:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 07349-02; Wed, 12 May 2004 07:13:36 -0300 (ADT) Received: from ns2.cksoft.de (ns2.cksoft.de [217.115.141.131]) by svr1.postgresql.org (Postfix) with ESMTP id CA54BD1B9EB; Wed, 12 May 2004 07:13:32 -0300 (ADT) Received: from vesihiisi.cksoft.de (unknown [192.168.64.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ns2.cksoft.de (Postfix) with ESMTP id 147022A444; Wed, 12 May 2004 12:13:33 +0200 (CEST) Received: from vesihiisi.cksoft.de (localhost [127.0.0.1]) by vesihiisi.cksoft.de (Postfix) with ESMTP id 7EA8C1F2E; Wed, 12 May 2004 12:13:27 +0200 (CEST) Received: by vesihiisi.cksoft.de (Postfix, from userid 1000) id DB4291F26; Wed, 12 May 2004 12:13:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by vesihiisi.cksoft.de (Postfix) with ESMTP id D3D3A1F1A; Wed, 12 May 2004 12:13:24 +0200 (CEST) Date: Wed, 12 May 2004 12:13:24 +0200 (CEST) From: Christian Kratzer To: Jie Liang Cc: pgsql-admin@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] \set In-Reply-To: Message-ID: <20040512120015.E61036@vesihiisi.cksoft.de> References: X-Spammer-Kill-Ratio: 75% MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by AMaViS cksoft-s20020300-20031204bz on vesihiisi.cksoft.de X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/147 X-Sequence-Number: 13463 Hi, On Tue, 11 May 2004, Jie Liang wrote: > Hi, > How to use an internal variable? > Original question was how to set a variable in postgresql? > If I want to set a variable like start_date='2004-05-10'; > How could I use it in my SQL statement? > E.g. > > Db> set start_date '2004-05-10' > Db> select start_date as 'start date'; > > It's not executable! from doc/postgresql/html/sql-set.html --snipp-- Synopsis SET [ SESSION | LOCAL ] name { TO | = } { value | 'value' | DEFAULT } SET [ SESSION | LOCAL ] TIME ZONE { timezone | LOCAL | DEFAULT } ... ... ... name Name of a settable run-time parameter. Available parameters are documented in Section 16.4 and below. --snipp-- that is you can only use SET to change specific predefined parameters. It does not say you could use SET to store other data local to the database session. As far as I know there are no session local variables in postgresql. I could use something like this myself. The only workaround I know of to have data local to a session is to create a temporary table for the data. There are local variables in plpgsql if you are just looking for local variables. Greetings Christian -- Christian Kratzer ck@cksoft.de CK Software GmbH http://www.cksoft.de/ Phone: +49 7452 889 135 Fax: +49 7452 889 136