为了批量添加数据
1,先构建要插入表的最大pk 最大值的函数
create or replace function f_get_tmp_content_maxid ##可以定义输入参数,同理sp
return char ##返回结果数据类型,不要带具体的数据类型长度比如:char(16)
as ###这个as下面和sp一样了
v_maxid char(16); ###这里要定义一个返回结果集的具体数据类型了,哈哈
beginselect lpad(max(chapter_id)+1,16,'0') into v_maxid from c_chapter_info;##用into接受这个返回的数据
return v_maxid;##用return子句返回处理结果 给应用或其他调用端end;
2,先构建序列
create sequence seq_only_maxid start with 65 increment by 1 nomaxvalue;
###注:以上序列最大值源于第1步函数得到的值
3, 从临时表中匹配提取用于插入到最终单节信息表的数据
select lpad(seq_only_maxid.nextval,16,'0'),a.* from (
select distinct *
from (
select chapter,version,version_id,subjectid,xiuid from tmp_content
)) a
select distinct *
from (
select chapter,version,version_id,subjectid,xiuid from tmp_content
)) a