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

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

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

        <tfoot id='mjzge'></tfoot>
      1. 我什么时候应该嵌套 PL/SQL BEGIN...END 块?

        When should I nest PL/SQL BEGIN...END blocks?(我什么时候应该嵌套 PL/SQL BEGIN...END 块?)
        <tfoot id='vp97a'></tfoot>

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

            <tbody id='vp97a'></tbody>

                <bdo id='vp97a'></bdo><ul id='vp97a'></ul>
                <i id='vp97a'><tr id='vp97a'><dt id='vp97a'><q id='vp97a'><span id='vp97a'><b id='vp97a'><form id='vp97a'><ins id='vp97a'></ins><ul id='vp97a'></ul><sub id='vp97a'></sub></form><legend id='vp97a'></legend><bdo id='vp97a'><pre id='vp97a'><center id='vp97a'></center></pre></bdo></b><th id='vp97a'></th></span></q></dt></tr></i><div id='vp97a'><tfoot id='vp97a'></tfoot><dl id='vp97a'><fieldset id='vp97a'></fieldset></dl></div>
                <legend id='vp97a'><style id='vp97a'><dir id='vp97a'><q id='vp97a'></q></dir></style></legend>
                • 本文介绍了我什么时候应该嵌套 PL/SQL BEGIN...END 块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 BEGIN...END 块中随意地将代码的子部分分组,这似乎是正确的.大多数情况下,当我处理一个更长的存储过程并且需要在一个地方使用一个临时变量时,我将只为那部分代码声明它.当我想识别和处理为特定代码段引发的异常时,我也会这样做.

                  I've been somewhat haphazardly grouping subsections of code in BEGIN...END blocks when it seems right. Mostly when I'm working on a longer stored procedure and there's a need for a temporary variable in one spot I'll declare it just for that portion of the code. I also do this when I want to identify and handle exceptions thrown for a specific piece of code.

                  为什么应该在一个过程、函数或另一个更大的 PL/SQL 块中嵌套块的任何其他原因?

                  Any other reasons why one should nest blocks within a procedure, function or another larger block of PL/SQL?

                  推荐答案

                  当你想像这样在本地处理异常时:

                  When you want to handle exceptions locally like this:

                  begin
                     for emp_rec in (select * from emp) loop
                        begin
                           my_proc (emp_rec);
                        exception
                           when some_exception then
                              log_error('Failed to process employee '||emp_rec.empno);
                        end;
                     end loop;
                  end;
                  

                  在这个例子中,异常被处理,然后我们继续处理下一个员工.

                  In this example, the exception is handled and then we carry on and process the next employee.

                  另一个用途是声明具有有限范围的局部变量,如下所示:

                  Another use is to declare local variables that have limited scope like this:

                  declare
                      l_var1 integer;
                      -- lots of variables
                  begin
                     -- lots of lines of code
                     ...
                     for emp_rec in (select * from emp) loop
                        declare
                           l_localvar integer := 0;
                        begin
                           -- Use l_localvar
                           ...
                        end
                     end loop;
                  
                  end;
                  

                  请注意,想要这样做通常表明您的程序太大,应该拆分:

                  Mind you, wanting to do this is often a sign that your program is too big and should be broken up:

                  declare
                     l_var1 integer;
                     -- lots of variables
                     ...
                     procedure local_proc (emp_rec emp%rowtype):
                        l_localvar integer := 0;
                     begin
                        -- Use l_localvar
                        ...
                     end
                  begin
                     -- lots of lines of code
                     ...
                     for emp_rec in (select * from emp) loop
                        local_proc (emp_rec);
                     end loop;
                  
                  end; 
                  

                  这篇关于我什么时候应该嵌套 PL/SQL BEGIN...END 块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

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

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

                    1. <tfoot id='jwyTb'></tfoot>
                          <legend id='jwyTb'><style id='jwyTb'><dir id='jwyTb'><q id='jwyTb'></q></dir></style></legend>

                            <tbody id='jwyTb'></tbody>

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