Unable to Create Temporary table in IBatis

510 Views Asked by At

I am unable to use temporary tables in my ibatis SQL Query (#table). This query is executed on SQL Server.

DECLARE @file_id int
SET @file_id  = 38--#FileID# 
SELECT * INTO #NotFinishedRecords FROM TABLE
1

There are 1 best solutions below

0
Tarun Sharma On

Here is the example of creating temp table in IBATIS using xml mapper:

<sqlMap namespace="xxx" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <select id="GetTempTableData" resultClass="xxx" parameterClass="System.String">
      Create table ##TestTable(ID varchar(20), Name varchar(100))
      Insert into ##TestTable values('1001-101','ABC')
      Insert into ##TestTable values('1001-102','XYZ')
      Select * from ##TestTable
  </select> 
</sqlMap>