X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 90BA5D905D for ; Thu, 15 Sep 2005 19:43:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62462-04 for ; Thu, 15 Sep 2005 22:43:04 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 83DA0D9059 for ; Thu, 15 Sep 2005 19:43:04 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j8FMh3XQ047648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 15 Sep 2005 16:43:05 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j8FMh3Bb071939; Thu, 15 Sep 2005 16:43:03 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j8FMh2vr071938; Thu, 15 Sep 2005 16:43:02 -0600 (MDT) (envelope-from mfuhr) Date: Thu, 15 Sep 2005 16:43:02 -0600 From: Michael Fuhr To: Geoffrey Knauth Cc: pgsql-sql@postgresql.org Subject: Re: passing values into .sql scripts Message-ID: <20050915224302.GA71883@winnie.fuhr.org> References: <8471ACDB-449A-4E67-8804-4407E81420B9@knauth.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8471ACDB-449A-4E67-8804-4407E81420B9@knauth.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200509/162 X-Sequence-Number: 22709 On Thu, Sep 15, 2005 at 05:27:52PM -0400, Geoffrey Knauth wrote: > I want to do something like this: > > \set tmp :acct 'a value' What's your intention here? The above sets the variable tmp to the value of the variable acct concatenated with 'a value', but you don't show acct being set anywhere. Did you mean to set acct? If so then try this: \set acct '\'a value\'' > \i query.sql > > where query.sql looks like this: > > select sum(amount), dr_acct from ledger where dr_acct = :acct > group by dr_acct; > select sum(amount), cr_acct from ledger where cr_acct = :acct > group by cr_acct; > select > (select sum(amount) from ledger where dr_acct = :acct ) > - (select sum(amount) from ledger where cr_acct = :acct ); > > However, this is what I get: > > psql:pnc.sql:1: ERROR: column "a value" does not exist What's pnc.sql? Is that the real name of the file you referred to as query.sql? -- Michael Fuhr