我接受过程中用户的表名和导出类型,并在过程中调用脚本。该脚本将接受表名作为参数。
------ SQL SCRIPT ----- 编辑csvfilename
set heading off
spool myfile.csv
select * from &1;
set colsep ','
spool off;
-----存储过程---------
SQL> CREATE OR REPLACE PROCEDURE Export_Table
2 (
3 tbl_nme IN varchar2,
4 export_type IN varchar2
5 )
6 AS
7 BEGIN
8 IF export_type = 'csv' THEN
9 EXECUTE IMMEDIATE '@csvfilename.sql tbl_name';
10 END IF;
11 END Export_Table;
12 /
Procedure created.
/
------ ---- ERROR
SQL> EXECUTE Export_Table('Mail','csv');
BEGIN Export_Table('Mail','csv'); END;
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at "TESTADMIN.EXPORT_TABLE", line 9
ORA-06512: at line 1
任何帮助都将不胜感激。