æ¶éè¦å¨oracle åå¨è¿ç¨ä¸æ§è¡å¨æSQL è¯å¥ ï¼ä¾å¦è¡¨åæ¯å¨æçï¼æå段æ¯å¨æçï¼
ææ¥è¯¢å½ä»¤æ¯å¨æçï¼å¯ç¨ä¸é¢çæ¹æ³ï¼
set serveroutput ondeclaren number;sql_stmt varchar2(50);
t varchar2(20);beginexecute immediate 'alter session set nls_date_format=''YYYYMMDD''';
t := 't_' || sysdate;
sql_stmt := 'select count(*) from ' || t;
execute immediate sql_stmt into n;
dbms_output.put_line('The number of rows of ' || t || ' is ' || n);end;
å¦æå¨æSQL è¯å¥ å¾é¿å¾å¤æï¼åå¯ç¨å
è£
.
CREATE OR REPLACE PACKAGE test_pkgISTYPE cur_typ IS REF CURSOR;
PROCEDURE test_proc (v_table VARCHAR2,t_cur OUT cur_typ);END;/
CREATE OR REPLACE PACKAGE BODY test_pkgISPROCEDURE test_proc (v_table VARCHAR2,t_cur OUT cur_typ)ISsqlstr VARCHAR2(2000);BEGINsqlstr := 'SELECT * FROM '||v_table;
OPEN t_cur FOR sqlstr;END;END;/
å¨oracle ä¸æ¹é导å
¥ï¼å¯¼åºåå é¤è¡¨å以æäºå符å¼å¤´ç表
spool c:\a.sql
温馨提示:答案为网友推荐,仅供参考