From: Geoffrey Knauth <geoff@knauth.org>
To: pgsql-sql@postgresql.org
Subject: passing values into .sql scripts
Date: Thu, 15 Sep 2005 17:27:52 -0400
Message-ID: <8471ACDB-449A-4E67-8804-4407E81420B9@knauth.org> (raw)
I want to do something like this:
\set tmp :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
Is there a different way I should be doing this? (I'm used to
Oracle's &1...&n parameters.)
Geoffrey
--
Geoffrey S. Knauth | http://knauth.org/gsk
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: geoff@knauth.org
Subject: Re: passing values into .sql scripts
In-Reply-To: <8471ACDB-449A-4E67-8804-4407E81420B9@knauth.org>
References: <8471ACDB-449A-4E67-8804-4407E81420B9@knauth.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