pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dinesh Pandey <dpandey@secf.com>
To: 'Juris Zeltins' <juris.zeltins@gmail.com>
Cc: 'PostgreSQL' <pgsql-sql@postgresql.org>
Subject: Re: dynamic 'INSERT'  query?
Date: Thu, 14 Apr 2005 17:33:13 +0530
Message-ID: <20050414120634.D513853646@svr1.postgresql.org> (raw)
In-Reply-To: <425E57DD.6060203@gmail.com>


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
>






view thread (5+ messages)  latest in thread

Message-ID: <20050414120634.D513853646@svr1.postgresql.org>
Permalink:  ../20050414120634.D513853646@svr1.postgresql.org/
Also on:    postgresql.org/message-id/20050414120634.D513853646@svr1.postgresql.org

 · 

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: dpandey@secf.com, juris.zeltins@gmail.com
  Subject: Re: dynamic 'INSERT'  query?
  In-Reply-To: <20050414120634.D513853646@svr1.postgresql.org>

* 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