什么是Ibatis SQL查询来检查表中是否存在列。我尝试了以下但是它给出了一个错误:
<select id="getAllAccountsWithLastName" resultClass="com.replication.Account">
if exists(select * from Information_schema.columns WHERE table_name='UserName' AND column_name = 'LastName')
begin
EXEC('select Acc.Acc accountNumber,
Acc.AccName description,
Acc.Staff staff,
UserName.LastName lastName,
RiskProfile.ProfileDesc riskProfileDesc
from Acc
join UserName on (Acc.AccID = UserName.AccID)
left join RiskProfile on (Acc.RiskProfileID = RiskProfile.RiskProfileID)
where Acc.AccStat = ''A''')
end
</select>
ERROR
Invalid column name 'LastName'.
相同的查询在SQL Server中有效。