CURSOR c_item (c_pro_id in number) is
SELECT ITEM_ID
FROM RS_SAL_SUB_ITEM_ON
where Com_Sql is not null and pro_id=c_pro_id;
我想直接查看执行结果 SELECT ITEM_ID
FROM RS_SAL_SUB_ITEM_ON
where Com_Sql is not null and pro_id=c_pro_id and (c_pro_id in number)
也就是只要求pro_id是个整数就可以了,或者类似的写法
SELECT ITEM_ID
FROM RS_SAL_SUB_ITEM_ON
where Com_Sql is not null and (pro_id in number)
就是想直接显示查询结果
CURSOR c_item (c_pro_id in number) is
SELECT ITEM_ID
FROM RS_SAL_SUB_ITEM_ON
where Com_Sql is not null
and pro_id=c_pro_id;
/
SELECT ITEM_ID
FROM RS_SAL_SUB_ITEM_ON
where Com_Sql is not null
and pro_id=c_pro_id
/
--上面这两种写法是一样的,
--只不过第一种写法使用带参数的游标,它适合于处理过程(out 参数)或者函数的返回值
SQL> declare
2 cursor c_emp (deptno_in in number) is
3 select ename,job,sal
4 from emp
5 where deptno=deptno_in;
6 begin
7 for v_c in c_emp(10) loop
8 dbms_output.put_line(v_c.ename||' '||v_c.job||' '||v_c.sal);
9 end loop;
10 end;
11 /
CLARK MANAGER 2450
KING PRESIDENT 5000
MILLER CLERK 1300
PL/SQL procedure successfully completedSQL> select ename,job,sal
2 from emp
3 where deptno=10
4 /
ENAME JOB SAL
---------- --------- ---------
CLARK MANAGER 2450.00
KING PRESIDENT 5000.00
MILLER CLERK 1300.00