Re: INSERT INTO problem

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: INSERT INTO problem
Дата
Msg-id 6534.982703513@sss.pgh.pa.us
обсуждение исходный текст
Ответ на INSERT INTO problem  (Tom Jenkins <tjenkins@devis.com>)
Список pgsql-general
Tom Jenkins <tjenkins@devis.com> writes:
> I eventually ended up with this line that still gives me the error:
> insert into reportentity
>    select 'D0'||text(departmentid) as reportentityid,
>    departmentname as reportentityname,
>    '1'::int2 as isdepartment,
>    departmentdescription as reportentitydescription,
>    departmentsummary as reportentitysummary
> from department where isreportentity > 0;

> Oh here's the format of the reportentity table:
> reportentityid char(5) not null
> reportentityname varchar(110) not null
> reportentitydescription  varchar(4000)
> reportentitysummary varchar(4000)
> isdepartment  int2

It looks like the order of the columns in the table doesn't match the
order of the SELECT outputs.  The 'AS' labels you're sticking on the
SELECT don't have anything to do with how the system will match things
up.  If you want to write the column values in the select in an order
different than they're declared in the table, you must do

insert into reportentity (reportentityid, reportentityname, isdepartment,
...) select 'D0'|| ...

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Re: A How-To: PostgreSQL from Tcl via ODBC
Следующее
От: Tom Lane
Дата:
Сообщение: Re: user meta (to the database, at least) information