<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="UserInfo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ibatis.apache.org/mapping">
<alias>
<typeAlias alias="MyUser" type="MainApp.MyUser" />
</alias>
<statements>
<!-- 동적 테이블 생성 -->
<statement id='Create_Login_Log'>
IF NOT EXISTS (SELECT 'X' FROM sysobjects where xtype = 'U' and name = 'Login_Log$yyyymm$')
BEGIN
create table Login_Log$yyyymm$
(
id int identity(1,1),
name nvarchar(100)
);
END;
IF NOT EXISTS (SELECT 'X' FROM sysobjects where xtype = 'U' and name = 'Login_Log2_$yyyymm$')
BEGIN
create table Login_Log2_$yyyymm$
(
id int,
name nvarchar(100)
);
END;
</statement>
<!-- 동적 생성 테이블 데이터 Insert -->
<insert id="Insert_Login_Log" resultClass="int" >
INSERT INTO Login_Log$yyyymm$ (name)
VALUES (#name#);
<selectKey resultClass="int" property="id" type="post" >
SELECT @@IDENTITY AS VALUE;
</selectKey>
</insert>
<!-- 동적 생성 테이블 데이터 Insert -->
<insert id="Insert_Login_Log2" resultClass="int" >
INSERT INTO Login_Log2_$yyyymm$ (id, name)
VALUES (#id#, #name#);
</insert>
<!-- 동적 테이블 데이터 조회 -->
<select id="Select_Login_Log">
SELECT *
FROM Login_Log$yyyymm$ a inner join Login_Log2_$yyyymm$ b on a.id = b.id
WHERE b.id = #id#;
</select>
</statements>
</sqlMap>