From: Michael Fuhr <mike@fuhr.org>
To: Geoffrey Knauth <geoff@knauth.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: passing values into .sql scripts
Date: Thu, 15 Sep 2005 16:43:02 -0600
Message-ID: <20050915224302.GA71883@winnie.fuhr.org> (raw)
In-Reply-To: <8471ACDB-449A-4E67-8804-4407E81420B9@knauth.org>
References: <8471ACDB-449A-4E67-8804-4407E81420B9@knauth.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@fuhr.org, geoff@knauth.org
Subject: Re: passing values into .sql scripts
In-Reply-To: <20050915224302.GA71883@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox