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

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

        <tfoot id='nhgy5'></tfoot>

        如何从存储过程返回多行?(Oracle PL/SQL)

        时间:2023-09-19

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

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

                1. 本文介绍了如何从存储过程返回多行?(Oracle PL/SQL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想创建一个带有一个参数的存储过程,它将根据参数返回不同的记录集.有什么方法可以做到这一点?我可以从普通 SQL 调用它吗?

                  I want to create a stored procedure with one argument which will return different sets of records depending on the argument. What is the way to do this? Can I call it from plain SQL?

                  推荐答案

                  这里是如何构建一个函数,该函数返回一个可以像表一样查询的结果集:

                  Here is how to build a function that returns a result set that can be queried as if it were a table:

                  SQL> create type emp_obj is object (empno number, ename varchar2(10));
                    2  /
                  
                  Type created.
                  
                  SQL> create type emp_tab is table of emp_obj;
                    2  /
                  
                  Type created.
                  
                  SQL> create or replace function all_emps return emp_tab
                    2  is
                    3     l_emp_tab emp_tab := emp_tab();
                    4     n integer := 0;
                    5  begin
                    6     for r in (select empno, ename from emp)
                    7     loop
                    8        l_emp_tab.extend;
                    9        n := n + 1;
                   10       l_emp_tab(n) := emp_obj(r.empno, r.ename);
                   11     end loop;
                   12     return l_emp_tab;
                   13  end;
                   14  /
                  
                  Function created.
                  
                  SQL> select * from table (all_emps);
                  
                       EMPNO ENAME
                  ---------- ----------
                        7369 SMITH
                        7499 ALLEN
                        7521 WARD
                        7566 JONES
                        7654 MARTIN
                        7698 BLAKE
                        7782 CLARK
                        7788 SCOTT
                        7839 KING
                        7844 TURNER
                        7902 FORD
                        7934 MILLER
                  

                  这篇关于如何从存储过程返回多行?(Oracle PL/SQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:没有聚合函数的 GROUP BY 下一篇:在 PL/SQL 中将逗号分隔的字符串转换为数组

                  相关文章

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

                  1. <tfoot id='Q5TsO'></tfoot>
                      <bdo id='Q5TsO'></bdo><ul id='Q5TsO'></ul>
                  2. <small id='Q5TsO'></small><noframes id='Q5TsO'>

                  3. <legend id='Q5TsO'><style id='Q5TsO'><dir id='Q5TsO'><q id='Q5TsO'></q></dir></style></legend>