copy from an site: SQL>! cat /tmp/test.sql dmbs_output.put_line('Test');SQL>create or replace procedure test_proc 2 is 3 begin 4 @/tmp/test.sql 5 end; 6 /Procedure created.SQL> select text from dba_source 2 where name = 'TEST_PROC';TEXT ---------------------------------------- create or replace procedure test_proc is begin dmbs_output.put_line('Test'); end;SQL> set serveroutput on SQL> exec test_proc TestPL/SQL procedure successfully completed.
create or replace procedure test_proc is begin @c:\sql.sql;end;Compilation errors for PROCEDURE CS.TEST_PROC 执行时就报以下错误 Error: PLS-00103: Encountered the symbol "@" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe Line: 4 Text: @c:\sql.sql;
应该是不行,在shell里执行吧。sqlplus和pl/sql是不一样的
after testing again,PassSQL> get f:\dbms.sql 1* insert into wyj values(1); SQL> get f:\proc.sql 1 create or replace procedure test_proc 2 is 3 begin 4 @f:\dbms.sql 5* end; SQL> @f:\proc.sqlProcedure created.SQL> exec test_procPL/SQL procedure successfully completed.SQL> select * from wyj; A ---------- 1 1
SQL> get c:\sql.sql 1* insert into wyj values(1); SQL> get c:\exec.sql 1 create or replace procedure test_proc 2 is 3 begin 4 @c:\sql.sql 5* end; SQL> @c:\exec.sqlProcedure created.SQL> exec test_procPL/SQL procedure successfully completed.SQL> select * from wyj 2 ; A ---------- 1 1 1
把procedure的语句放在一个文件里就不会抱错了。。
我测试怎么报错????????? SQL> get c:\sql.sql 1* select * from tabs SQL> get c:\exec.sql 1 create or replace procedure test_proc 2 is 3 begin 4 @c:\sql.sql 5* end; SQL> @c:\exec.sql 6 /警告: 创建的过程带有编译错误。SQL> get c:\exec.sql 1 create or replace procedure test_proc 2 is 3 begin 4 @c:\sql.sql 5* end; SQL> @c:\exec.sql警告: 创建的过程带有编译错误。SQL> exec test_proc BEGIN test_proc; END; * ERROR 位于第 1 行: ORA-06550: 第 1 行, 第 7 列: PLS-00905: 对象 SIPDB.TEST_PROC 无效 ORA-06550: 第 1 行, 第 7 列: PL/SQL: Statement ignored
,你看自己需要做什么才能看怎么操作的阿
SQL>! cat /tmp/test.sql
dmbs_output.put_line('Test');SQL>create or replace procedure test_proc
2 is
3 begin
4 @/tmp/test.sql
5 end;
6 /Procedure created.SQL> select text from dba_source
2 where name = 'TEST_PROC';TEXT
----------------------------------------
create or replace procedure test_proc
is
begin
dmbs_output.put_line('Test');
end;SQL> set serveroutput on
SQL> exec test_proc
TestPL/SQL procedure successfully completed.
is
begin
@c:\sql.sql;end;Compilation errors for PROCEDURE CS.TEST_PROC
执行时就报以下错误
Error: PLS-00103: Encountered the symbol "@" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
Line: 4
Text: @c:\sql.sql;
1* insert into wyj values(1);
SQL> get f:\proc.sql
1 create or replace procedure test_proc
2 is
3 begin
4 @f:\dbms.sql
5* end;
SQL> @f:\proc.sqlProcedure created.SQL> exec test_procPL/SQL procedure successfully completed.SQL> select * from wyj; A
----------
1
1
1* insert into wyj values(1);
SQL> get c:\exec.sql
1 create or replace procedure test_proc
2 is
3 begin
4 @c:\sql.sql
5* end;
SQL> @c:\exec.sqlProcedure created.SQL> exec test_procPL/SQL procedure successfully completed.SQL> select * from wyj
2 ; A
----------
1
1
1
SQL> get c:\sql.sql
1* select * from tabs
SQL> get c:\exec.sql
1 create or replace procedure test_proc
2 is
3 begin
4 @c:\sql.sql
5* end;
SQL> @c:\exec.sql
6 /警告: 创建的过程带有编译错误。SQL> get c:\exec.sql
1 create or replace procedure test_proc
2 is
3 begin
4 @c:\sql.sql
5* end;
SQL> @c:\exec.sql警告: 创建的过程带有编译错误。SQL> exec test_proc
BEGIN test_proc; END; *
ERROR 位于第 1 行:
ORA-06550: 第 1 行, 第 7 列:
PLS-00905: 对象 SIPDB.TEST_PROC 无效
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored