Re: passing values into .sql scripts

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: passing values into .sql scripts
Дата
Msg-id 20050915224302.GA71883@winnie.fuhr.org
обсуждение исходный текст
Ответ на passing values into .sql scripts  (Geoffrey Knauth <geoff@knauth.org>)
Ответы Re: passing values into .sql scripts  (Geoffrey Knauth <geoff@knauth.org>)
Список pgsql-sql
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


В списке pgsql-sql по дате отправления:

Предыдущее
От: The One
Дата:
Сообщение: How to install Postgresql 8 on different drive letter?
Следующее
От: Geoffrey Knauth
Дата:
Сообщение: Re: passing values into .sql scripts