[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: [GENERAL] query ... returned 4 columns
From:       Tom Lane <tgl () sss ! pgh ! pa ! us>
Date:       2007-03-10 5:42:46
Message-ID: 7942.1173505366 () sss ! pgh ! pa ! us
[Download RAW message or body]

Sorin Schwimmer <sxn02@yahoo.com> writes:
> Having the same structure, I put
> INSERT INTO archive.expected_stuff VALUES(o);
> but it doesn't work. Instead, I had to rewrite as
> INSERT ... VALUES (o.source,o.warehouse...);

Of course.  The former command implies that you are inserting a
composite value into a single composite-type column of expected_stuff,
which you are not.

The right way to express this IMHO is
	INSERT INTO archive.expected_stuff VALUES(o.*);
which should expand into the longhand notation "o.source,o.warehouse..."
in the same way that "SELECT o.* FROM ..." would do.  This does actually
work in 8.2 (and maybe 8.1, I forget).  In older releases you gotta
write it out longhand :-(

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic