pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dinesh Pandey <dpandey@secf.com>
To: 'PostgreSQL' <pgsql-sql@postgresql.org>
Subject: dynamic 'INSERT'  query?
Date: Thu, 14 Apr 2005 17:07:54 +0530
Message-ID: <20050414114131.C840B53726@svr1.postgresql.org> (raw)

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: <20050414114131.C840B53726@svr1.postgresql.org>
Permalink:  ../20050414114131.C840B53726@svr1.postgresql.org/
Also on:    postgresql.org/message-id/20050414114131.C840B53726@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
  Subject: Re: dynamic 'INSERT'  query?
  In-Reply-To: <20050414114131.C840B53726@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