Thread: escaping string in a function

escaping string in a function

From
"Shuying Wang"
Date:
Hi,

I'm trying to write a function that would the results of select 'foo'
. How do I
escape strings within a create function block?

Thanks,
Shuying

Re: escaping string in a function

From
"Shuying Wang"
Date:
I think I should also add that I'm using PostgreSQL 7.3

On 3/2/06, Shuying Wang <wang.shuying.lists@gmail.com> wrote:
> Hi,
>
> I'm trying to write a function that would the results of select 'foo'
> . How do I
> escape strings within a create function block?
>
> Thanks,
> Shuying
>

Re: escaping string in a function

From
Michael Fuhr
Date:
On Thu, Mar 02, 2006 at 02:24:09PM +1100, Shuying Wang wrote:
> I'm trying to write a function that would the results of select 'foo'.
> How do I escape strings within a create function block?

It's not clear what you're trying to do -- could you explain a
little more?  Does the following example help?

CREATE FUNCTION func() RETURNS text AS '
  SELECT ''foo''::text
' LANGUAGE sql IMMUTABLE;

--
Michael Fuhr