In VBA, I am trying to use OraDynaSet object to create a temporary table and fetch some data into it before using it for another select.
strSQL = "create table user1.new12 as(" _
& "Select lca.coupon_upc,lca.division from lca where lca.campaign_id = " & campaign_id & "" _
& "MINUS " _
& " Select mcr.coupon_upc,mcr.division from mcr where mcr.campaign_id = " & campaign_id & ")"
Set OraDynaSet = objdatabase.DBCreateDynaset(strSQL, o&)
I have opened up the connection with the user user1 to perform a number of select queries before executing this DDL. Now, when I execute the VBA code, it throws an error "ORA:009955 Name is used by an existing object". Where am i going wrong?
If you're just using that temporary table for a single follow-on query, then it might be easier just to use an "inline view":
select t.coupon_upc, t.division from
(select lca.coupon_upc,lca.division from lca where lca.campaign_id = campaign_id
MINUS
select mcr.coupon_upc,mcr.division from mcr where mcr.campaign_id = campaign_id) t
where {clauses here...}
Tim
The table already exists. You are not creating a temporary table but a standard table: it will remain in the database after your script has ended. If you have already run this script and you have not dropped the table, the following executions will fail.
In Oracle Global temporary table are persistent objects that contain temporary data. In most cases if you need to use a temporary table regularly (because it is part of a recurrent process), you would create the table once only.