begin;
insert into tabName(id, script_name) values (nextval('tabName_id_seq'), #{scriptName,jdbcType=VARCHAR});
<selectKey resultType="Integer" keyProperty="id">
select currval('tabName_id_seq') as id;
</selectKey>
insert into tabName2(id,)values ((select distinct currval('tabName_id_seq') from tabName_id) :: INTEGER);
commit
或者
获取返回map id 使用 map 形式
<insert id="add" useGeneratedKeys="true" keyProperty="id" keyColumn="id">