I am new to PostgreSQL (v8.4) and I am trying to write some simple functions. My first experiment, however, is already ending in a grim failure. I get an error message:
ERROR: syntax error at or near ";" LINE 7: begin;
... and I do not see the problem. This looks correct according to the documentation I was looking through.
create or replace function create_user( user_name varchar(250), email_address varchar(250), approved boolean, email_is_unique boolean ) returns boolean as $$ begin; if email_is_unique && exists(select null from users as u where u.email = email_address) then raise exception 'The email address specified is already in use, and email addresses are configured to be unique.'; end if; insert into users ( user_name, email ) values ( user_name, email_address ); return true; end; $$ language plpgsql;
postgresql
Jeremy Holovacs Dec 16 '11 at 17:03 2011-12-16 17:03
source share