pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rodrigo De León <rdeleonp@gmail.com>
To: pgsql-sql@postgresql.org
Cc: Nemo Terry <ntuser155@hotmail.com>
Subject: Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)'; "?
Date: Tue, 15 May 2007 01:25:25 -0500
Message-ID: <a55915760705142325u33359969wef53e8bd20bdbc11@mail.gmail.com> (raw)
In-Reply-To: <BAY19-F2416AC2716765516AB4824F53D0@phx.gbl>
References: <BAY19-F2416AC2716765516AB4824F53D0@phx.gbl>

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.



view thread (6+ messages)  latest in thread

Message-ID: <a55915760705142325u33359969wef53e8bd20bdbc11@mail.gmail.com>
Permalink:  ../a55915760705142325u33359969wef53e8bd20bdbc11@mail.gmail.com/
Also on:    postgresql.org/message-id/a55915760705142325u33359969wef53e8bd20bdbc11@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rdeleonp@gmail.com, ntuser155@hotmail.com
  Subject: Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)'; "?
  In-Reply-To: <a55915760705142325u33359969wef53e8bd20bdbc11@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox