- 论坛徽章:
- 0
|
如何在存储过程中变量传递表名,在cursor中调用?
我的脚步如下:
CREATE OR REPLACE PROCEDURE Dfsc_Yhqfxx (dwbm IN VARCHAR2, ny IN VARCHAR2)
AS
table_name_yhda varchar(1 ;
CURSOR S_YS(table_name varchar2,P_HH VARCHAR2,P_YDNY VARCHAR2) IS SELECT YSDF FROM table_name WHERE YDNY=P_YDNY AND HH=P_HH;
begin
--拼凑要处理的表名
table_name_yhda:='DFSC.DFCD_YHDA'||'_'||'15'||'_'||'2004';
OPEN S_YS(table_name_yhdf,'100000338','200405'); --取当前用户应收
IF S_YS%FOUND THEN
FETCH S_YS INTO v_row.ys;
ELSE
V_row.ys:=0;
DBMS_OUTPUT.PUT_LINE(v_row.YHH||'应收无法取得');
END IF;
CLOSE S_YS;
end; |
|