Re: Select and functions - Mailing list pgsql-sql

From Jeff Eckermann
Subject Re: Select and functions
Date
Msg-id 20031105195424.7444.qmail@web20803.mail.yahoo.com
Whole thread Raw
In response to Select and functions  ("Stephen J. Thompson" <stephen@cass-ltd.co.uk>)
List pgsql-sql
--- "Stephen J. Thompson" <stephen@cass-ltd.co.uk>
wrote:

> But if I use it in a before trigger the procedure
> fails to work. 
> 
> CREATE OR REPLACE FUNCTION
> staging.write_work_country()
>   RETURNS trigger AS
> '
>     DECLARE
>         alias_rec RECORD;
>     BEGIN
>         -- Clean the phone number
>         NEW.worktelephonenumber =
> REPLACE(NEW.worktelephonenumber,' ','');
>         RETURN NEW;
>     END;
> ' 
> 
> I get the following error:
> 
> ERROR:  parser: parse error at or near "','');
> 
> Can anyone help me please?

Single quotes inside function bodies need to be
escaped.  The easiest way is to double them, i.e. from
one single quote to two single quotes.  Backslashes
would work just as well (and also need to be escaped
if used in a function body).

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree


pgsql-sql by date:

Previous
From:
Date:
Subject: Re: Select and functions
Next
From: Jerome Alet
Date:
Subject: avoid circular references