Thread: RAISE EXCEPTION not working

RAISE EXCEPTION not working

From
"Brian H Mayo"
Date:

I am trying the use the following statements in a function:

            SELECT INTO temp_i id FROM public.t_customer_profile WHERE

                                    id=cust_id;

                  IF NOT FOUND THEN

                        RAISE EXCEPTION "Username already exists";

                  END IF;    

 

I know the table and the select statement is correct.

And I keep receiving the following error:

WARNING:  plpgsql: ERROR during compile of f_insert_login_profile_record near line 19

 

ERROR:  syntax error at or near ""Username already exists""

 

I do not understand why.

 

Thank you.

Brian H Mayo

bmayo@comcast.net

 

Re: RAISE EXCEPTION not working

From
Stephan Szabo
Date:
On Thu, 20 Nov 2003, Brian H Mayo wrote:

> I am trying the use the following statements in a function:
>             SELECT INTO temp_i id FROM public.t_customer_profile WHERE
>                                     id=cust_id;
>                   IF NOT FOUND THEN
>                         RAISE EXCEPTION "Username already exists";
I think you want:
RAISE EXCEPTION ''Username already exists'';
(quoted text literals in SQL use single quotes, since it's in a quoted
function body, you'll need to use two single quotes).