Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)';"? - Mailing list pgsql-sql

From Rodrigo De León
Subject Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)';"?
Date
Msg-id a55915760705142325u33359969wef53e8bd20bdbc11@mail.gmail.com
Whole thread Raw
In response to How to process inverted comma in "EXECUTE 'insert into xxx values(...)';"?  ("Nemo Terry" <ntuser155@hotmail.com>)
Responses Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)  ("Nemo Terry" <ntuser155@hotmail.com>)
List pgsql-sql
On 5/14/07, Nemo Terry <ntuser155@hotmail.com> wrote:
> Look at this problem:
> when
> execute 'insert into lse_installations values(' || ''''||obj_id||'''' || ',' || ''''||div||'''' || ',' ||
''''||sub||''''|| ',' || ''''||obj_type||'''' || ',' || ''''||obj_name||'''' || ',' || ''''||pstcd||'''' || ',' ||
''''||rdcd||''''|| ',' || ''''||blkno||'''' || ',' || ''''||vldunt||'''' || ','|| cenlat || ',' || cenlon || ')';
 
> because obj_name from another table has value like this:S'pore High Polymer.
> Following error raises:
> ERROR: syntax error at or near "pore"
> SQL state: 42601
> Context: PL/pgSQL function "lse_installations" line 64 at execute statement
>
> So how to process the single inverted comma in char variable?It makes me so desperate.

Why are you EXECUTEing the INSERT command? It's directly supported in
plpgsql, since it is a superset of SQL. That is, you can do:

INSERT INTO lse_installations    VALUES (obj_id, div, sub, obj_type, obj_name, pstcd, rdcd, blkno, vldunt          ,
cenlat,cenlon);
 

Good luck.


pgsql-sql by date:

Previous
From: "Nemo Terry"
Date:
Subject: How to process inverted comma in "EXECUTE 'insert into xxx values(...)';"?
Next
From: "Nemo Terry"
Date:
Subject: Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)