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

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

  1. <legend id='AzfO3'><style id='AzfO3'><dir id='AzfO3'><q id='AzfO3'></q></dir></style></legend>
  2. <tfoot id='AzfO3'></tfoot>
      <bdo id='AzfO3'></bdo><ul id='AzfO3'></ul>

      ORACLE 11g 中的表值函数?(参数化视图)

      时间:2023-09-19
      • <small id='Uar00'></small><noframes id='Uar00'>

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

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

              <tbody id='Uar00'></tbody>
            <legend id='Uar00'><style id='Uar00'><dir id='Uar00'><q id='Uar00'></q></dir></style></legend><tfoot id='Uar00'></tfoot>
              1. 本文介绍了ORACLE 11g 中的表值函数?(参数化视图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我过去曾看到过关于此的讨论,例如 此处.但我想知道是否在某个地方,也许是 10g 或 11g(我们正在使用 11g),ORACLE 引入了对参数化视图"的任何更好的支持,而无需用各种用户定义的类型和/或游标定义或 sys_context 变量.

                I've seen discussions about this in the past, such as here. But I'm wondering if somewhere along the line, maybe 10g or 11g (we are using 11g), ORACLE has introduced any better support for "parameterized views", without needing to litter the database with all sorts of user-defined types and/or cursor definitions or sys_context variables all over.

                我希望 ORACLE 可能会根据以下 T-SQL 示例添加对简单有效"的东西的支持:

                I'm hoping maybe ORACLE's added support for something that simply "just works", as per the following example in T-SQL:

                CREATE FUNCTION [dbo].[getSomeData] (@PRODID ROWID)  
                RETURNS TABLE AS  
                    RETURN SELECT PRODID, A, B, C, D, E  
                    FROM MY_TABLE  
                    WHERE PRODID = @PRODID
                

                然后就这样选择它:

                SELECT * FROM dbo.getSomeData(23)
                

                推荐答案

                不需要 SYS_CONTEXT 或游标定义.您确实需要一个类型,以便在解析 SQL 时,它可以确定要返回哪些列.也就是说,您可以轻松编写一个脚本,根据 user_tab_columns 中的数据为一个或多个表生成类型和集合类型定义.

                No need for SYS_CONTEXT or cursor definitions. You do need a type so that, when the SQL is parsed, it can determine which columns are going to be returned. That said, you can easily write a script that will generate type and collection type definitions for one or more tables based on the data in user_tab_columns.

                最近的是

                create table my_table
                (prodid number, a varchar2(1), b varchar2(1), 
                  c varchar2(1), d varchar2(1), e varchar2(1));
                
                create type my_tab_type is object
                (prodid number, a varchar2(1), b varchar2(1), 
                  c varchar2(1), d varchar2(1), e varchar2(1))
                .
                /
                
                create type my_tab_type_coll is table of my_tab_type;
                /
                
                create or replace function get_some_data (p_val in number) 
                return my_tab_type_coll pipelined is
                begin
                  FOR i in (select * from my_table where prodid=p_val) loop
                    pipe row(my_tab_type(i.prodid,i.a,i.b,i.c,i.d,i.e));
                  end loop;
                  return;
                end;
                /
                
                SELECT * FROM table(get_Some_Data(3));
                

                这篇关于ORACLE 11g 中的表值函数?(参数化视图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Oracle 中的第 N 个最高工资 下一篇:Oracle 是否支持全文搜索?

                相关文章

                <legend id='9azt4'><style id='9azt4'><dir id='9azt4'><q id='9azt4'></q></dir></style></legend>

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

                      <bdo id='9azt4'></bdo><ul id='9azt4'></ul>