<insert id=...>
<selectKey keyColumn="some_id" keyProperty="someId" order="BEFORE" resultType="int">
select s_seq1.nextval from dual
</selectKey>
insert into some_table
(some_id, some_data, created_on, created_by)
values
(#{someId}, #{someData}, #{createdOn}, #{createdBy})
</insert>
我们现在正试图使用Derby数据库为应用程序编写集成测试,但由于该数据库没有双表,我们试图通过创建一个名为dual的假视图来实现上述查询,该视图包含序列nextval表达式作为其列。用两个示例列分解变更集如下
<changeSet id="create_dual_view">
<sql><![CDATA[create view dual as select 1 "s_seq1.nextval", 2 "s_seq2.nextval" from SYSIBM.SYSDUMMY1;]]></sql>
</changeSet>
通过检查Derby内容,成功创建了此视图,但是在运行测试时,我们仍然收到上述查询的异常
java.sql.SQLSyntaxErrorException: Column 'S_SEQ1.NEXTVAL' is either not in any table in the FROM list or appears within a join specification
and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list.