Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)

From: "Nemo Terry" <ntuser155(at)hotmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)
Date: 2007-05-15 06:50:17
Message-ID: BAY19-F7C1E88EB8DBB10FEBC7D1F53D0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

But I must use it in function,so...
Do you have another solution?

>From: "Rodrigo De Le" <rdeleonp(at)gmail(dot)com>
>To: pgsql-sql(at)postgresql(dot)org
>CC: "Nemo Terry" <ntuser155(at)hotmail(dot)com>
>Subject: Re: [SQL] How to process inverted comma in "EXECUTE 'insert into xxx values(...)';"?
>Date: Tue, 15 May 2007 01:25:25 -0500
>
>On 5/14/07, Nemo Terry <ntuser155(at)hotmail(dot)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.
>
>---------------------------(end of
>broadcast)---------------------------
>TIP 6: explain analyze is your friend

_________________________________________________________________
与联机的朋友进行交流,请使用 Live Messenger; http://get.live.com/messenger/overview

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2007-05-15 07:12:55 Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)
Previous Message Rodrigo De León 2007-05-15 06:25:25 Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)'; "?