On Apr 14, 2005, at 7:37 AM, 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 || ’)’;


Dinesh,

I think what you are showing here IS the way to build up a dynamic sql statement. I'm not sure that you can write a prepared statement within the body of a function, which would then look more like what you are suggesting you want to do--perhaps others on the list can enlighten us about that. In any case, why won't using the || operator work for you?

Sean


---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Reply via email to