Function syntax error
CREATE OR REPLACE FUNCTION public.handle_sign_up()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF SECURITY DEFINER
AS $BODY$
BEGIN
if new.raw_user_meta_data->>'user_type' = 'carer' then
insert into public.carers (user_id, level, status, application_status)
values (new.id, 0, 0, 'registered');
return new;
else if new.raw_user_meta_data->>'user_type' = 'client' then
insert into public.clients (user_id)
values (new.id);
return new;
else
RAISE EXCEPTION 'Invalid user type: %', new.raw_user_meta_data->>'user_type';
end if;
return null;
END;
$BODY$;CREATE OR REPLACE FUNCTION public.handle_sign_up()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF SECURITY DEFINER
AS $BODY$
BEGIN
if new.raw_user_meta_data->>'user_type' = 'carer' then
insert into public.carers (user_id, level, status, application_status)
values (new.id, 0, 0, 'registered');
return new;
else if new.raw_user_meta_data->>'user_type' = 'client' then
insert into public.clients (user_id)
values (new.id);
return new;
else
RAISE EXCEPTION 'Invalid user type: %', new.raw_user_meta_data->>'user_type';
end if;
return null;
END;
$BODY$;I'm not sure why but if I try to get this function in my Supabase it errors with:
syntax error at or near ";"syntax error at or near ";"What am I doing wrong?