oracle存储过程中应该是一个session先进行insert多条数据没有commit查询不到数据

xunfanglv 2016-12-12 05:50:42
insert into gq_data_epr_project(item_3_1,item_3_2,item_3_3,item_3_4,pos_code)
select extractvalue(org, '/com_proposal/basic_info/xm_no'),
extractvalue(org, '/com_proposal/basic_info/xm_name'),
to_date(extractvalue(org,'/com_proposal/basic_info/start_date'),'yyyy-mm-dd'),
extractvalue(org,'/com_proposal/basic_info/kfxm_jsly_value'),
v_pos_code
from (select x1.column_value as org
from xmltable('data/com_proposals/com_proposal' passing
v_proposal_xml) x1) x2;
--更新技术领域,将技术领域更新为对接要求的方式
declare
cursor c_job is select t.pos_code,t.item_3_1,t.item_3_2,t.item_3_3 from gq_data_epr_project t where t.pos_code=v_pos_code;
c_row c_job%rowtype;
v_item_3_4 varchar2(10);
v_pid_1 varchar2(10);
v_pid_2 varchar2(10);
v_item_str varchar2(100);
begin
select t.item_3_4 into v_item_3_4 from gq_data_epr_project t where t.item_3_1=c_row.item_3_1 and t.item_3_2=c_row.item_3_2 and t.item_3_3=c_row.item_3_3 and t.pos_code=c_row.pos_code;
select t.pid into v_pid_1 from const_gxjsqy_tech_new_temp t where t.option_val=v_item_3_4;
select t.pid into v_pid_2 from const_gxjsqy_tech_new_temp t where t.option_val=v_pid_1;
v_item_str:=v_pid_2||','||v_pid_1||','||v_item_3_4;
update gq_data_epr_project t set t.item_3_1=v_item_str where t.item_3_1=c_row.item_3_1 and t.item_3_2=c_row.item_3_2 and t.item_3_3=c_row.item_3_3 and t.pos_code=c_row.pos_code;
end;


如上sql都是在一个存储过程中,先使用一个insert into 语句,插入多条数据到gq_data_epr_project表中,此处没有使用commit,断点调试到定义游标时查询不到数据,按说应该是在一个session内,就算没有commit,应该也是能查询到数据的吧,为什么查不到数据呢,如果不使用commit,还有其他的解决方法吗?
...全文
624 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jdsnhan 2016-12-13
  • 打赏
  • 举报
回复
1、确认

 select extractvalue(org, '/com_proposal/basic_info/xm_no'),
                 extractvalue(org, '/com_proposal/basic_info/xm_name'),
                 to_date(extractvalue(org,'/com_proposal/basic_info/start_date'),'yyyy-mm-dd'),
                 extractvalue(org,'/com_proposal/basic_info/kfxm_jsly_value'),
                 v_pos_code
            from (select x1.column_value as org
                    from xmltable('data/com_proposals/com_proposal' passing
                                  v_proposal_xml) x1) x2;
是否有正确的结果集 2、确认游标里面的select条件是正确的
sych888 2016-12-12
  • 打赏
  • 举报
回复
SQL> create table t(id int,name varchar2(20)); 表已创建。 SQL> declare 2 begin 3 insert into t select empno,ename from emp; 4 for c in (select * from t) loop 5 dbms_output.put_line('id='||c.id); 6 end loop; 7 end; 8 / id=7369 id=7499 id=7521 id=7566 id=7654 id=7698 id=7782 id=7788 id=7839 id=7844 id=7876 id=7900 id=7902 id=7934 PL/SQL 过程已成功完成。
卖水果的net 2016-12-12
  • 打赏
  • 举报
回复
执行完 insert 后,打印一下 SQL%ROWCOUNT ,看看是否真的写入了数据;

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧