Re: dynamic 'INSERT' query?
От | Sean Davis |
---|---|
Тема | Re: dynamic 'INSERT' query? |
Дата | |
Msg-id | e9917654069296414165126cade4505c@mail.nih.gov обсуждение исходный текст |
Ответ на | dynamic 'INSERT' query? ("Dinesh Pandey" <dpandey@secf.com>) |
Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: