• <tfoot id='vPUjA'></tfoot>
    <i id='vPUjA'><tr id='vPUjA'><dt id='vPUjA'><q id='vPUjA'><span id='vPUjA'><b id='vPUjA'><form id='vPUjA'><ins id='vPUjA'></ins><ul id='vPUjA'></ul><sub id='vPUjA'></sub></form><legend id='vPUjA'></legend><bdo id='vPUjA'><pre id='vPUjA'><center id='vPUjA'></center></pre></bdo></b><th id='vPUjA'></th></span></q></dt></tr></i><div id='vPUjA'><tfoot id='vPUjA'></tfoot><dl id='vPUjA'><fieldset id='vPUjA'></fieldset></dl></div>
      • <bdo id='vPUjA'></bdo><ul id='vPUjA'></ul>

      <small id='vPUjA'></small><noframes id='vPUjA'>

      <legend id='vPUjA'><style id='vPUjA'><dir id='vPUjA'><q id='vPUjA'></q></dir></style></legend>

        在 Oracle 中调用另一个存储过程

        时间:2023-09-19
          <bdo id='XDthx'></bdo><ul id='XDthx'></ul>
            <tbody id='XDthx'></tbody>
          • <legend id='XDthx'><style id='XDthx'><dir id='XDthx'><q id='XDthx'></q></dir></style></legend>

              1. <i id='XDthx'><tr id='XDthx'><dt id='XDthx'><q id='XDthx'><span id='XDthx'><b id='XDthx'><form id='XDthx'><ins id='XDthx'></ins><ul id='XDthx'></ul><sub id='XDthx'></sub></form><legend id='XDthx'></legend><bdo id='XDthx'><pre id='XDthx'><center id='XDthx'></center></pre></bdo></b><th id='XDthx'></th></span></q></dt></tr></i><div id='XDthx'><tfoot id='XDthx'></tfoot><dl id='XDthx'><fieldset id='XDthx'></fieldset></dl></div>
                <tfoot id='XDthx'></tfoot>

                <small id='XDthx'></small><noframes id='XDthx'>

                1. 本文介绍了在 Oracle 中调用另一个存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有谁知道从另一个内部调用存储过程的方法,或者即使可能的话?如果是这样,你会怎么做?

                  Does anyone know of a way, or even if its possible, to call a stored procedure from within another? If so, how would you do it?

                  这是我的测试代码:

                  SET SERVEROUTPUT ON;
                  
                  DROP PROCEDURE test_sp_1;
                  DROP PROCEDURE test_sp;
                  
                  CREATE PROCEDURE test_sp
                  AS
                  BEGIN
                      DBMS_OUTPUT.PUT_LINE('Test works');
                  END;
                  /
                  
                  CREATE PROCEDURE test_sp_1
                  AS
                  BEGIN
                      DBMS_OUTPUT.PUT_LINE('Testing');
                      test_sp;
                  END;
                  /
                  
                  CALL test_sp_1;
                  

                  推荐答案

                  您的存储过程按编码工作.问题出在最后一行,它无法调用您的任何一个存储过程.

                  Your stored procedures work as coded. The problem is with the last line, it is unable to invoke either of your stored procedures.

                  SQL*Plus 中的三个选项是:callexec 和一个匿名的 PL/SQL 块.

                  Three choices in SQL*Plus are: call, exec, and an anoymous PL/SQL block.

                  call 似乎是一个 SQL 关键字,并记录在 SQL 参考中.http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_4008.htm#BABDEHHG 语法图表明需要括号,即使没有参数传递给调用例程.

                  call appears to be a SQL keyword, and is documented in the SQL Reference. http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_4008.htm#BABDEHHG The syntax diagram indicates that parentesis are required, even when no arguments are passed to the call routine.

                  CALL test_sp_1();
                  

                  匿名 PL/SQL 块是不在命名过程、函数、触发器等内部的 PL/SQL.它可用于调用您的过程.

                  An anonymous PL/SQL block is PL/SQL that is not inside a named procedure, function, trigger, etc. It can be used to call your procedure.

                  BEGIN
                      test_sp_1;
                  END;
                  /
                  

                  Exec 是一个 SQL*Plus 命令,它是上述匿名块的快捷方式.EXEC 将作为 BEGIN 传递给数据库服务器;结束;

                  Exec is a SQL*Plus command that is a shortcut for the above anonymous block. EXEC <procedure_name> will be passed to the DB server as BEGIN <procedure_name>; END;

                  完整示例:

                  SQL> SET SERVEROUTPUT ON
                  SQL> CREATE OR REPLACE PROCEDURE test_sp 
                    2  AS 
                    3  BEGIN 
                    4      DBMS_OUTPUT.PUT_LINE('Test works'); 
                    5  END;
                    6  /
                  
                  Procedure created.
                  
                  SQL> CREATE OR REPLACE PROCEDURE test_sp_1 
                    2  AS
                    3  BEGIN
                    4      DBMS_OUTPUT.PUT_LINE('Testing'); 
                    5      test_sp; 
                    6  END;
                    7  /
                  
                  Procedure created.
                  
                  SQL> CALL test_sp_1();
                  Testing
                  Test works
                  
                  Call completed.
                  
                  SQL> exec test_sp_1
                  Testing
                  Test works
                  
                  PL/SQL procedure successfully completed.
                  
                  SQL> begin
                    2      test_sp_1;
                    3  end;
                    4  /
                  Testing
                  Test works
                  
                  PL/SQL procedure successfully completed.
                  
                  SQL> 
                  

                  这篇关于在 Oracle 中调用另一个存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 SELECT 语句中使用 BOOLEAN 类型 下一篇:IN 子句中的 SQL 多列

                  相关文章

                  1. <small id='PaSyW'></small><noframes id='PaSyW'>

                    • <bdo id='PaSyW'></bdo><ul id='PaSyW'></ul>

                    <legend id='PaSyW'><style id='PaSyW'><dir id='PaSyW'><q id='PaSyW'></q></dir></style></legend>

                    1. <tfoot id='PaSyW'></tfoot>
                    2. <i id='PaSyW'><tr id='PaSyW'><dt id='PaSyW'><q id='PaSyW'><span id='PaSyW'><b id='PaSyW'><form id='PaSyW'><ins id='PaSyW'></ins><ul id='PaSyW'></ul><sub id='PaSyW'></sub></form><legend id='PaSyW'></legend><bdo id='PaSyW'><pre id='PaSyW'><center id='PaSyW'></center></pre></bdo></b><th id='PaSyW'></th></span></q></dt></tr></i><div id='PaSyW'><tfoot id='PaSyW'></tfoot><dl id='PaSyW'><fieldset id='PaSyW'></fieldset></dl></div>