<bdo id='6t0p2'></bdo><ul id='6t0p2'></ul>

    <small id='6t0p2'></small><noframes id='6t0p2'>

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

        从 PL/SQL 块运行 SCRIPT

        Run SCRIPT from PL/SQL Block(从 PL/SQL 块运行 SCRIPT)
          <tbody id='eUTyA'></tbody>

          <legend id='eUTyA'><style id='eUTyA'><dir id='eUTyA'><q id='eUTyA'></q></dir></style></legend>
              <bdo id='eUTyA'></bdo><ul id='eUTyA'></ul>

            • <small id='eUTyA'></small><noframes id='eUTyA'>

              <tfoot id='eUTyA'></tfoot>

                  <i id='eUTyA'><tr id='eUTyA'><dt id='eUTyA'><q id='eUTyA'><span id='eUTyA'><b id='eUTyA'><form id='eUTyA'><ins id='eUTyA'></ins><ul id='eUTyA'></ul><sub id='eUTyA'></sub></form><legend id='eUTyA'></legend><bdo id='eUTyA'><pre id='eUTyA'><center id='eUTyA'></center></pre></bdo></b><th id='eUTyA'></th></span></q></dt></tr></i><div id='eUTyA'><tfoot id='eUTyA'></tfoot><dl id='eUTyA'><fieldset id='eUTyA'></fieldset></dl></div>
                • 本文介绍了从 PL/SQL 块运行 SCRIPT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在pl/sql块中使用START SCRIPT"?

                  How to use "START SCRIPT" in pl/sql block ?

                  我想用这样的东西

                  declare
                  begin
                     proc(para1,para2);
                     execute immediate 'start prompt1' ; 
                  end;
                  /
                  

                  我还想知道,我可以从 prompt1 获取一个值到我调用脚本的 PL/SQL 块中吗?因为我需要使用该值在PL/SQL块中执行一些操作.

                  Also I want to know , can i get a value from prompt1 into my PL/SQL block where am calling the script ? Because I need to use the value to perform some operations in the PL/SQL block.

                  推荐答案

                  现在是 2012 2017 年.脚本是上个千年的笨拙而脆弱的残留物.Oracle 具有我们可以在 PL/SQL 中执行的大量功能,此外还有 Java 存储过程和用于启动作业的调度.除了运行 DDL 来创建或修改模式之外,在 Oracle 数据库环境中几乎不需要脚本;甚至 DDL 脚本也应该从外部客户端触发,可能是诸如 TeamCity 之类的构建工具.

                  It is 2012 2017. Scripts are a clunky and brittle hangover from the last millennium. Oracle has a fantastic range of functionality we can execute in PL/SQL, plus there's Java Stored Procedures, and there's scheduling for starting jobs. Other than running DDL to create or amend schemas there is hardly any need for scripts in an Oracle database environment; even DDL scripts should be triggered from an external client, probably a build tool such as TeamCity.

                  特别是,我认为尝试从 PL/SQL 程序运行 SQL 脚本是架构失败.你用存储过程不能做的脚本做什么?

                  In particular I would regard attempting to run a SQL script from a PL/SQL program as an architectural failure. What are you doing with the script which you cannot do with a stored procedure?

                  至于将输入传递给存储过程,这就是参数的用途.PL/SQL 不是交互式的,我们需要一个客户端来输入值.根据场景,这可以异步(文件或表中的值)或同步(从 SQL*Plus、SQL Developer 或定制前端调用存储过程)完成.

                  As for passing input to a stored procedure, that's what parameters are for. PL/SQL isn't interactive, we need a client to enter the values. Depending on the scenario this can be done asynchronously (values in a file or a table) or synchronously (calling the stored procedure from SQL*Plus, SQL Developer or a bespoke front end).

                  话虽如此,在现实世界中,我们使用杂乱的架构,数据库和外部操作系统之间存在相互依赖关系.那我们能做什么?

                  Having said all that, in the real world we work with messy architectures with inter-dependencies between the database and the external OS. So what can we do?

                  1. 我们可以编写一个 Java 存储过程来执行 shell 命令.这是一个古老的解决方案,自 Oracle 8i 以来一直存在.了解更多.
                  2. 在 10g 中,Oracle 将 DBMS_JOB 替换为 DBMS_SCHEDULER.该工具的一个增强功能是它能够运行外部作业,即 shell 脚本.查找更多.
                  3. 由于 Oracle 11g R1 外部表支持预处理器脚本,该脚本在查询表之前运行 shell 命令.了解更多.

                  请注意,所有这些选项都需要提升访问权限(授予目录对象、安全凭据等).这些只能由特权用户(即 DBA)授予.除非我们的数据库有一个惊人的宽松的安全配置,否则我们无法从 PL/SQL 运行任意的 shell 脚本.

                  Note that all these options demand elevated access (grants on DIRECTORY objects, security credentials, etc). These can only be granted by privileged users (i.e. DBAs). Unless our database has an astonishingly lax security configuration there is no way for us to run an arbitrary shell script from PL/SQL.

                  最后,不清楚在 PL/SQL 中运行 SQL 脚本有什么好处.请记住,PL/SQL 在数据库服务器上运行,因此它无法在客户端机器上看到脚本.鉴于接受用户输入的要求,这似乎很重要.

                  Finally, it is not clear what benefit you expect from running a SQL script in PL/SQL. Remember that PL/SQL runs on the database server, so it can't see scripts on the client machine. This seems relevant in the light of the requirement to accept user input.

                  也许最简单的解决方案是重新配置原始脚本.将必要的 PL/SQL 调用拆分成一个块,然后只调用命名脚本:

                  Perhaps the simplest solution is reconfiguration of the original script. Split out the necessary PL/SQL call into a block and then just call the named script:

                  begin
                     proc(para1,para2);
                  end;
                  /   
                  @prompt1.sql
                  

                  这篇关于从 PL/SQL 块运行 SCRIPT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                  How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                  Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                  Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                  Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                  Reset Sequence in oracle 11g(oracle 11g 中的重置序列)
                • <small id='vcoNm'></small><noframes id='vcoNm'>

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

                            <bdo id='vcoNm'></bdo><ul id='vcoNm'></ul>

                              <tbody id='vcoNm'></tbody>
                          • <tfoot id='vcoNm'></tfoot>