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