Re: [SQL] what exactly is a query structure?

2010-02-25 Thread A. Kretschmer
In response to silly sad : > hello. > > Postgresql 8.3.9 > > CREATE TYPE usr_secrets AS (login TEXT, pass TEXT, shop_pass TEXT); > > CREATE OR REPLACE FUNCTION get_noobs () RETURNS SETOF usr_secrets AS $$ > BEGIN > RETURN QUERY SELECT login, '*' as pass, shop_pass FROM noob; > RETURN; > END;

[SQL] what exactly is a query structure?

2010-02-25 Thread silly sad
hello. Postgresql 8.3.9 CREATE TYPE usr_secrets AS (login TEXT, pass TEXT, shop_pass TEXT); CREATE OR REPLACE FUNCTION get_noobs () RETURNS SETOF usr_secrets AS $$ BEGIN RETURN QUERY SELECT login, '*' as pass, shop_pass FROM noob; RETURN; END; $$ LANGUAGE plpgsql SECURITY DEFINER; SELECT *

Re: [SQL] Using new.id in the WHERE condition of one UPDATE inside ON INSERT rule

2010-02-25 Thread Tom Lane
Aron writes: > I would like to avoid using "SELECT MAX(id) FROM my_table" (it doesn't seem a > good method), but if I use "new.id", I get new id values, not the "id" > inserted with the rule, and the condition is always false. "new.id" is a macro, which in this example will be expanded into a n

[SQL] Using new.id in the WHERE condition of one UPDATE inside ON INSERT rule

2010-02-25 Thread Aron
I would like to avoid using "SELECT MAX(id) FROM my_table" (it doesn't seem a good method), but if I use "new.id", I get new id values, not the "id" inserted with the rule, and the condition is always false. Complete example (it works because it doesn't use new.id inside condition): DROP TABLE