Thanks Pavel, but I have an SQL procedure and not plpgsql?

On Sun, Oct 31, 2010 at 9:34 AM, Pavel Stehule <pavel.steh...@gmail.com> wrote:
>> But how can I detect that the UPDATE has failed in my SQL procedure?
>>
>
> see: 
> http://www.postgresql.org/docs/8.4/interactive/plpgsql-control-structures.html
> near to end of page

>>        create or replace function update_pref_users(id varchar,
>>            first_name varchar, last_name varchar, female boolean,
>>            avatar varchar, city varchar, last_ip inet) returns void as $$
>>
>>                update pref_users set
>>                    first_name = $2,
>>                    last_name = $3,
>>                    female = $4,
>>                    avatar = $5,
>>                    city = $6,
>>                    last_ip = $7
>>                where id = $1;
>>
>>                -- XXX how to detect failure here? XXX
>>
>>                insert into pref_users(id, first_name, last_name,
>>                    female, avatar, city, last_ip)
>>                    values ($1, $2, $3, $4, $5, $6, $7);
>>        $$ language sql;

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to