oracle PL/SQL程序问题,涉及游标(求助)
说明:
根据表Z_TEST的字段AAA的值来更新Z_TEST的字段BBB的值;
表ZZ_TEMPAGENCY的字段CODE和Z_TEST的字段aaa具有关联关系,然后取出ZZ_TEMPAGENCY的字段NEWCODE的值赋给Z_TEST的字段BBB;
Declare
tcode z_test.aaa%type;
Cursor cur1 Is select AAA from z_test for update of z_test.bbb;
Begin
Open cur1;
-- Loop
Fetch cur1 Into tcode;
dbms_output.put_line(tcode);--ok
Declare
tnewcode zz_tempagency.newcode%type;
Cursor cur2 is select zz_tempagency.newcode from zz_tempagency where ZZ_TEMPAGENCY.CODE=tcode;--问题出在这儿:条件中赋值有问题,查出来结果是空。为什么?
Begin
dbms_output.put_line('第二次打印tcode');
dbms_output.put_line(tcode);--tcode的值是期望的值
Open cur2;
Fetch cur2 into tnewcode;
dbms_output.put_line(tnewcode||'------');--tnewcode的值为空,为什么呢?
update z_test set z_test.bbb=tnewcode where z_test.aaa=tcode;
Close cur2;
End;
-- Exit When cur1%NotFound;
--End Loop;
Close cur1;
---Commit;
End;