Re: psql - user defined SQL variables
От | Tino Wildenhain |
---|---|
Тема | Re: psql - user defined SQL variables |
Дата | |
Msg-id | 1092806896.7846.68.camel@Andrea.peacock.de обсуждение исходный текст |
Ответ на | psql - user defined SQL variables (Grainne Reilly <greilly1@comcast.net>) |
Список | pgsql-general |
Hi, Am Mi, den 18.08.2004 schrieb Grainne Reilly um 6:22: > I am new to PostgreSQL and am porting some scripts written for MySQL over > to psql. There is one MySQL feature which I cannot find in psql - user > defined SQL variables. In MySQL I can use these to hold the result > (numeric, string or null) of a select: e.g. > select @count = count(*) from mytable; > The @count variable now holds the result of that select, and I can use it > in where clauses, updates, inserts etc. > I checked out the \set psql variable but I haven't found a way to tweak it > to give me the result of a sql statement - is there any way to do that (I'm > using PostgreSQL version 7.4.3)? > Thanks in advance for any suggestions, > Grainne. Postgres supports subselects (for update and stuff) and you can insert like that: INSERT INTO foo (a,b,c) SELECT a,b,c FROM ... If thats not enough, you have a bounch of pl/* languages to write sophisticated procedures in the database where you have variables for single values as well as recordsets. Regards Tino Wildenhain
В списке pgsql-general по дате отправления: