如题,的命令符下sql>可以执行@c:\sql.sql命令来执行脚本文件,如果写到存储过程里如何写?

解决方案 »

  1.   

    存储过程中不能直接出现select,update,delete这样的语句,需要用双引号引起来,其它的都差不多的
    ,你看自己需要做什么才能看怎么操作的阿
      

  2.   

    c:\sql.sql里的内容是insert语句,在命令符下可以执行sql>@c:\sql.sql来进行批量插入数据,我意思是怎么把这个命令入到存储过程里,c:\sql.sql作为参数传入来执行批量插入.
      

  3.   

    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.
      

  4.   

    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;
      

  5.   

    应该是不行,在shell里执行吧。sqlplus和pl/sql是不一样的
      

  6.   

    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
      

  7.   

    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
      

  8.   

    把procedure的语句放在一个文件里就不会抱错了。。
      

  9.   

    我测试怎么报错?????????
    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
      

  10.   

    procedure里直接select * from 肯定抱错的。。