I am trying to execute the sql script shown below via jdbcTemplate.execute(....);
if object_id('#dao_bulk_trade') is not null
exec('drop table #dao_bulk_trade')
create table #dao_bulk_trade(thread varchar(128),contract_id int null,contract_version int null)
IF EXISTS (SELECT * FROM tempdb..sysindexes WHERE id=OBJECT_ID('#dao_bulk_trade') AND name='ncidx1')
exec('drop index #dao_bulk_trade.ncidx1')
create unique nonclustered index ncidx1 on #dao_bulk_trade (thread, contract_id)
The first time I call the corresponding DAO endpoint via swagger it executes the SQL script and creates the table. If I however, I then make the same call again via swagger it blows up with the error below.
"Cannot create temporary table '#dao_bulk_trade'. Prefix name '#dao_bulk_trade' is already in use by another temporary table '#dao_bulk_trade'."
I have auto commit set to true on my jdbc connections in the Hikari pool. I am at a loss as to what the problem is.