Re: INSERT INTO problem

Поиск
Список
Период
Сортировка
От Tom Jenkins
Тема Re: INSERT INTO problem
Дата
Msg-id 3A92D7A4.6030304@devis.com
обсуждение исходный текст
Ответ на Re: INSERT INTO problem  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-general
Stephan Szabo wrote:

> On Tue, 20 Feb 2001, Tom Jenkins wrote:
>
>> Hello all,
>> I'm trying to do an INSERT INTO using a UNION of two selects.  I
>> received an error:
>>   "ERROR:  Unable to convert varchar to int2 for column isdepartment"
>>
>> I started simplifying the INSERT INTO to help me get to the root cause.
>> I removed the UNION and continued simplifying.
>>
>> 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;
>
>
> I do not believe that it uses the aliases you give to say which columns
> those are associated with.  I think you need to have the select items
> in the same order as the columns, so, it's erroring trying to convert
> a departmentsummary value to an int2.  Reordering the columns should
> help.

You are correct!  I rearranged the columns, matching the order of the
table, and the INSERT INTO ... UNION... works now.

Thank you very much.

Tom Jenkins
devIS - Development Infostructure
http://www.devis.com


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

Предыдущее
От: Tomek Zielonka
Дата:
Сообщение: Re: Postgres slowdown on large table joins
Следующее
От: "Gregory Wood"
Дата:
Сообщение: Re: Printing PostgreSQL reports