Re: [HACKERS] variables in psql

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] variables in psql
Дата
Msg-id 23775.928272369@sss.pgh.pa.us
обсуждение исходный текст
Ответ на variables in psql  (Keala Jacobs <keala_jacobs@itd.sterling.com>)
Список pgsql-hackers
Keala Jacobs <keala_jacobs@itd.sterling.com> writes:
> Does postgres support the use of variables as in the example below?

> update table1 set column1=@variable
> where column2='text4column2'
> and @variable=(select column3 from table2 where column4='text4column4');

> If not, how do I execute a statement like this in postgres?

That isn't a particularly compelling example, since it looks like what
you mean is the same as

update table1 set column1 = table2.column3
where table1.column2 = 'text4column2' and table2.column4 = 'text4column4';

I have seen examples where it'd be nice to have an SQL variable that
could hold a value from one statement to the next; currently you have
to do that with a temporary table, which seems rather cumbersome...

BTW, I think this'd be more appropriate in pgsql-sql.
        regards, tom lane


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

Предыдущее
От: Peter T Mount
Дата:
Сообщение: Re: [HACKERS] Re: [SQL] Column name's length
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Re: [SQL] Column name's length