Re: Passing a String with special character as an input

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: akp geek <akpgeek(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Passing a String with special character as an input
Date: 2010-11-24 03:42:39
Message-ID: AANLkTime-Pr74SCdUGQAcs-vGZqwnKOginpdcnRFh-x4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2010/11/23 akp geek <akpgeek(at)gmail(dot)com>:
> Hi -
>            This is related to my earlier post. For the function I am passing
> a string. But the string some time has a single quote inside the string like
> "IT's a String Test" , How can I handle that, can you please help?

on stored procedure level you can do nothing

in SQL level, you have to duble quotes

like INSERT INTO data VALUES('Peter''s book');

regards

Pavel Stehule

>
>
> CREATE OR REPLACE FUNCTION test_repl(x character varying)
>   RETURNS character varying AS
> $BODY$
> DECLARE
> ret_var varchar(4000);
> a record;
> begin
> ret_var := x;
> for a in select * from lookup
> loop
>   ret_var := replace(ret_var,a.code,a.codeword);
> end loop;
> return ret_var;
> END;
> $BODY$
>   LANGUAGE 'plpgsql' VOLATILE
>   COST 100;
> ALTER FUNCTION test_repl(character varying) OWNER TO postgres;

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2010-11-24 05:28:43 Re: Passing a String with special character as an input
Previous Message Craig Ringer 2010-11-24 00:01:07 Re: What is Dialect