agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
insert values from a ROW object
5+ messages / 3 participants
[nested] [flat]

* insert values from a ROW object
@ 2016-09-22 21:42 Michael Moore <michaeljmoore@gmail.com>
  2016-09-22 21:44 ` Re: insert values from a ROW object Michael Moore <michaeljmoore@gmail.com>
  2016-09-22 21:55 ` Re: insert values from a ROW object David G. Johnston <david.g.johnston@gmail.com>
  2016-09-22 22:20 ` Re: insert values from a ROW object Thomas Kellerer <spam_eater@gmx.net>
  0 siblings, 3 replies; 5+ messages in thread

From: Michael Moore @ 2016-09-22 21:42 UTC (permalink / raw)
  To: pgsql-sql

for a in select * from temp_rslt
loop
   insert into final_rslt select row(a.*);
end loop;

I want to do something like the above. I don't want to have to name each
'a.' variable.
Is it possible?

TIA
Mike

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: insert values from a ROW object
  2016-09-22 21:42 insert values from a ROW object Michael Moore <michaeljmoore@gmail.com>
@ 2016-09-22 21:44 ` Michael Moore <michaeljmoore@gmail.com>
  2 siblings, 0 replies; 5+ messages in thread

From: Michael Moore @ 2016-09-22 21:44 UTC (permalink / raw)
  To: pgsql-sql

by the way, the row structure of temp_rslt and final_rslt are identical.


On Thu, Sep 22, 2016 at 2:42 PM, Michael Moore <michaeljmoore@gmail.com>
wrote:

> for a in select * from temp_rslt
> loop
>    insert into final_rslt select row(a.*);
> end loop;
>
> I want to do something like the above. I don't want to have to name each
> 'a.' variable.
> Is it possible?
>
> TIA
> Mike
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: insert values from a ROW object
  2016-09-22 21:42 insert values from a ROW object Michael Moore <michaeljmoore@gmail.com>
@ 2016-09-22 21:55 ` David G. Johnston <david.g.johnston@gmail.com>
  2016-09-22 22:38   ` Re: insert values from a ROW object Michael Moore <michaeljmoore@gmail.com>
  2 siblings, 1 reply; 5+ messages in thread

From: David G. Johnston @ 2016-09-22 21:55 UTC (permalink / raw)
  To: Michael Moore <michaeljmoore@gmail.com>; +Cc: pgsql-sql

On Thu, Sep 22, 2016 at 2:42 PM, Michael Moore <michaeljmoore@gmail.com>
wrote:

> for a in select * from temp_rslt
> loop
>    insert into final_rslt select row(a.*);
> end loop;
>
> I want to do something like the above. I don't want to have to name each
> 'a.' variable.
> Is it possible?
>
>
INSERT INTO final_rslt VALUES ( (a).* );

David J.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: insert values from a ROW object
  2016-09-22 21:42 insert values from a ROW object Michael Moore <michaeljmoore@gmail.com>
  2016-09-22 21:55 ` Re: insert values from a ROW object David G. Johnston <david.g.johnston@gmail.com>
@ 2016-09-22 22:38   ` Michael Moore <michaeljmoore@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Michael Moore @ 2016-09-22 22:38 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-sql

Thanks David.
Thomas, Yes, in my example the loop is not necessary, but in my real
application it is. :-) Thanks.

On Thu, Sep 22, 2016 at 2:55 PM, David G. Johnston <
david.g.johnston@gmail.com> wrote:

> On Thu, Sep 22, 2016 at 2:42 PM, Michael Moore <michaeljmoore@gmail.com>
> wrote:
>
>> for a in select * from temp_rslt
>> loop
>>    insert into final_rslt select row(a.*);
>> end loop;
>>
>> I want to do something like the above. I don't want to have to name each
>> 'a.' variable.
>> Is it possible?
>>
>>
> INSERT INTO final_rslt VALUES ( (a).* );
>
> David J.
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: insert values from a ROW object
  2016-09-22 21:42 insert values from a ROW object Michael Moore <michaeljmoore@gmail.com>
@ 2016-09-22 22:20 ` Thomas Kellerer <spam_eater@gmx.net>
  2 siblings, 0 replies; 5+ messages in thread

From: Thomas Kellerer @ 2016-09-22 22:20 UTC (permalink / raw)
  To: pgsql-sql

Michael Moore schrieb am 22.09.2016 um 23:42:
> for a in select * from temp_rslt
> loop
>    insert into final_rslt select row(a.*);
> end loop;
>
> I want to do something like the above. I don't want to have to name each 'a.' variable.
> Is it possible?
>

No need for a loop:

   insert into final_rsl
   select *
   from tmp_rslt;

This assumes that both table define the columns in the exact same order







-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2016-09-22 22:38 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 21:42 insert values from a ROW object Michael Moore <michaeljmoore@gmail.com>
2016-09-22 21:44 ` Michael Moore <michaeljmoore@gmail.com>
2016-09-22 21:55 ` David G. Johnston <david.g.johnston@gmail.com>
2016-09-22 22:38   ` Michael Moore <michaeljmoore@gmail.com>
2016-09-22 22:20 ` Thomas Kellerer <spam_eater@gmx.net>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox