Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert with union

Status
Not open for further replies.

alexhu

MIS
Sep 25, 2001
1,288
GB
I am trying to do this (the real code is a bit large - so for brevity....)

insert into <table>
select a.column, b.column
from table_a table_b
where <statement>
union
select a.column, b.column
from table_a table_b
where <statement>

and I get the error

ERROR at line 1: <table>
ORA-00947: not enough values

Can I do this or not ?

Alex
 
This may mean that your <table> contains more than 2 fields. I also can not find neither a nor b aliases in your statement.

Regards, Dima
 
yes it does (23 columns per statement)

I take it thats a no-no then ?

Alex
 
Obviously the table you are inserting into has more number of columns than your select statement. You may want to specify the columns you want to insert into.

Try this insted,

insert into <table> (col1,col2)
select a.column, b.column
from table_a table_b
where <statement>
union
select a.column, b.column
from table_a table_b
where <statement>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top