Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 5B87C9FB5BE for ; Tue, 15 May 2007 03:25:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 51588-03 for ; Tue, 15 May 2007 03:25:26 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.250]) by postgresql.org (Postfix) with ESMTP id C1F3D9FB514 for ; Tue, 15 May 2007 03:25:26 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id d17so481401and for ; Mon, 14 May 2007 23:25:26 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=QgREjjUtraYgnzIVR6XqAsmupn4MpVzh/jNGDDAwHDY5jDopwp4vT3smVmgsLW66KQsV4eyvLKf50Bcwz1Mp/2rPtDKGMuFfpEApwTD+WuHV5hAtXY/b6L6zosjGGCMlH74lNH36GBmTmJk9DNlUmjSeUhrd20bXDcNznZBf9Sk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OIKey9RDXplf4PXz/WHez4TMUqR0/Yn8tNN21b6PX5/D9cGWRJN3ah9R8Ygr8H4FcDgKmyM2QNMiyNz1GIC8Oi0VQ8FBxgzY1QZMzGhMvL1LP84RVOEA18V6dIDCNFZTZNbjiWbYqdmzG8f2x/veME/5rd0/XEHFrLiCdo91USI= Received: by 10.100.110.16 with SMTP id i16mr5102045anc.1179210325892; Mon, 14 May 2007 23:25:25 -0700 (PDT) Received: by 10.100.154.9 with HTTP; Mon, 14 May 2007 23:25:25 -0700 (PDT) Message-ID: Date: Tue, 15 May 2007 01:25:25 -0500 From: "=?ISO-8859-1?Q?Rodrigo_De_Le=F3n?=" To: pgsql-sql@postgresql.org Subject: Re: How to process inverted comma in "EXECUTE 'insert into xxx values(...)'; "? Cc: "Nemo Terry" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/117 X-Sequence-Number: 28397 On 5/14/07, Nemo Terry 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.