I have a table which I need to perform actions on and then insert the result in a temp table so I can join the temp table with other tables later. Here's my code:
if object_id ('tempdb..tempMHR_X') is not null
drop table tempMHR_X;
create table tempMHR_X (
tempTM_LINE_ITEM_SA_ID int,
tempMH_X int,
tempCHRG_DT_MONTH int,
tempCHRG_DT_YEAR int
)
insert into tempMHR_X (tempTM_LINE_ITEM_SA_ID, tempMH_X, tempCHRG_DT_MONTH, tempCHRG_DT_YEAR)
select tc.TM_LINE_ITEM_SA_ID, sum(tc.MH_X), extract(month from tc.CHRG_DT), extract(year from tc.CHRG_DT)
from TM_CHARGE tc
group by tc.TM_LINE_ITEM_SA_ID, extract(month from tc.CHRG_DT), extract(year from tc.CHRG_DT)
I am getting an 'ORA-00922: Missing or invalid operation' error on the insert statement. I have tested everything from the beginning of the select statement down and it returned the correct result. Now, I just want get that result into the temp table tempMH_X so I can join the temp table with other tables.
FYI, I am using an Oracle 10g database. I have tried using the '#' sign before my temp table name, but TOAD says that is an invalid operator. Any help is much appreciated. Thank you!
James