X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3B80A53689 for ; Thu, 14 Apr 2005 09:06:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22309-06 for ; Thu, 14 Apr 2005 12:06:36 +0000 (GMT) Received: from secf.com (209-128-104-244.bayarea.net [209.128.104.244]) by svr1.postgresql.org (Postfix) with ESMTP id D513853646 for ; Thu, 14 Apr 2005 09:06:34 -0300 (ADT) Received: from dinesh by secf.com (MDaemon.PRO.v7.2.2.R) with ESMTP id md50000632922.msg for ; Thu, 14 Apr 2005 05:05:54 -0700 Reply-To: From: "Dinesh Pandey" To: "'Juris Zeltins'" Cc: "'PostgreSQL'" Subject: Re: dynamic 'INSERT' query? Date: Thu, 14 Apr 2005 17:33:13 +0530 Organization: Second Foundation India P Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Thread-Index: AcVA6Ee77Kn9jtcBRE+utxpzPwRjuAAAYp0g In-Reply-To: <425E57DD.6060203@gmail.com> X-Authenticated-Sender: dpandey@secf.com X-Spam-Processed: mail.secf.com, Thu, 14 Apr 2005 05:05:54 -0700 (not processed: message from valid local sender) X-MDRemoteIP: 220.227.32.11 X-Return-Path: dpandey@secf.com X-MDaemon-Deliver-To: pgsql-sql@postgresql.org X-MDAV-Processed: mail.secf.com, Thu, 14 Apr 2005 05:05:55 -0700 Message-Id: <20050414120634.D513853646@svr1.postgresql.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.503 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, MSGID_FROM_MTA_ID, UPPERCASE_25_50 X-Spam-Level: * X-Archive-Number: 200504/190 X-Sequence-Number: 21083 FOR _record IN SELECT A1, A2 FROM A LOOP --[Dinesh Pandey] -- Sorry I didn't get this part. _sql := "INSERT INTO B VALUES ( '*" || _record.A1 || "'** , '" || _record.A2 || "' ***)"; EXECUTE (_sql); END LOOP; Dinesh Pandey wrote: > How can we set A1, A2 values in dynamic 'INSERT' query? > > DECLARE > > _record RECORD; > > _sql VARCHAR(2000); > > FOR _record IN SELECT A1, A2 FROM A > > LOOP > > _sql := 'INSERT INTO B VALUES (*:A1, :A2*)'; > > EXECUTE (_sql); > > END LOOP; > > ================================================================= > > I can do this as (but I need another way instead of using || operator). > > _sql := 'INSERT INTO B VALUES (' || _record.A1 || ',' || _record.A2 || > ')'; > > ================================================================= > > Regards > Dinesh Pandey > > > *--------------------------------------------------------------------------- -------* > *Dinesh Pandey* > Sr. Software Engineer >