Re: [SQL] returning inserted id

2005-08-27 Thread Havasvölgyi Ottó
Matt, This is how you can do it: create function person_ins(_name text) returns integer language plpgsql as $$ declare insert_id integer; begin insert into person (name) values(_name); select into insert_id currval('person_id_seq'); return insert_id; end; $$; Or perhaps even better: you return

Re: [SQL] nullif('','') on insert

2005-08-27 Thread Bruno Wolff III
> Your problem is that NULL's are typed in PostgreSQL. > > Try this: > > SELECT NULL; > SELECT NULL::BOOL; > SELECT NULL::BOOL::TEXT; > > to see what I mean. This is an exact illustration of your problem. Note that in 8.1 he will be able to do: SELECT NULL::TEXT::INT::BOOL and get the conversi

Re: [SQL] Unwanted nested dollar-quoted constants

2005-08-27 Thread Tom Lane
Bernard Henry Voynet <[EMAIL PROTECTED]> writes: > All the text fields are specified using the dollar-quoted string constant > form that. This is your mistake to start with. You can not simply stick a couple of dollar signs around a random string and expect to have a valid literal, any more than