我的存储过程如下:
create or replace procedure YearPalnToMonth(tid in T_TRANSACTION_OBJECT.T_ID%Type,userID in char,PlanMonth in char,sucessed out boolean) is
vTID varchar(64);
vDID varchar(64);
vTempID varchar(32);
vUsedID varchar(64);
type Cur is ref cursor;
v_DeviceCur Cur;
begin
sucessed := false;
select S_SEQ_TRANSACTION.NEXTVAL into vTempID from dual;
vTID := userID||'@'||vTempID;
insert into T_PLAN_OBJECT values (vTID,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
update T_PLAN_OBJECT set (period_unit,period_length,executor_id,executor_nr,executor_name,beginning_date,end_date,ora_id,ora_nr,ora_name,maker_id,maker_nr,maker_name,make_date)=(select period_unit,period_length,executor_id,executor_nr,executor_name,beginning_date,end_date,ora_id,ora_nr,ora_name,maker_id,maker_nr,maker_name,make_date from T_PLAN_OBJECT where T_ID=tid) where T_ID=vTID;
commit;
sucessed :=true;
end;执行过程中没有任何问题,但是结果update语句好像是没有执行,数据库中只有insert进去的数据,update的数据没有写进去,但是把update语句拎出来以后变量替换一下就可以的。期待ing.

解决方案 »

  1.   

    呵呵,执行 insert 的时候,数据还没有提交到数据库,那么下一句 update 的时候就会发现找不到刚刚insert的那条记录,所以执行的最后结果是只存在insert的记录
    解决方法: insert后增加一次commit;
      

  2.   

    不是很明白为什么要插入语句的时候为什么要拆分成insert 和update 来实现,迷惑ing
      

  3.   

    加了commit也不行啊,写成一个Instert怎么写啊??除了几个数据指定外其他的从原有表中取
      

  4.   

    1楼,在一个事务中是不需要commit的
    update T_PLAN_OBJECT set (period_unit,period_length,executor_id,executor_nr,executor_name,beginning_date,end_date,ora_id,ora_nr,ora_name,maker_id,maker_nr,maker_name,make_date)=(select period_unit,period_length,executor_id,executor_nr,executor_name,beginning_date,end_date,ora_id,ora_nr,ora_name,maker_id,maker_nr,maker_name,make_date from T_PLAN_OBJECT where T_ID=tid) where T_ID=vTID;
    T_ID=tid???? 
    select period_unit,period_length,executor_id,executor_nr,executor_name,beginning_date,end_date,ora_id,ora_nr,ora_name,maker_id,maker_nr,maker_name,make_date from T_PLAN_OBJECT where T_ID=tid,能查询出记录吗?
      

  5.   

    回上面的,把UPdate语句拎出来,把变量替换就是要的结果了,测试的时候存储过程里变量也是有正确值的
      

  6.   

    把变量替换就是要的结果了,我怀疑就是变量有问题
    tid是传入变量,不执行过程,select能查询出结果吗?