• <tfoot id='hBQlI'></tfoot>
  • <legend id='hBQlI'><style id='hBQlI'><dir id='hBQlI'><q id='hBQlI'></q></dir></style></legend>
      <bdo id='hBQlI'></bdo><ul id='hBQlI'></ul>

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

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

      1. 如何在 SELECT FROM 语句中使用表类型?

        How to use a table type in a SELECT FROM statement?(如何在 SELECT FROM 语句中使用表类型?)
          <i id='DXCNc'><tr id='DXCNc'><dt id='DXCNc'><q id='DXCNc'><span id='DXCNc'><b id='DXCNc'><form id='DXCNc'><ins id='DXCNc'></ins><ul id='DXCNc'></ul><sub id='DXCNc'></sub></form><legend id='DXCNc'></legend><bdo id='DXCNc'><pre id='DXCNc'><center id='DXCNc'></center></pre></bdo></b><th id='DXCNc'></th></span></q></dt></tr></i><div id='DXCNc'><tfoot id='DXCNc'></tfoot><dl id='DXCNc'><fieldset id='DXCNc'></fieldset></dl></div>
            • <small id='DXCNc'></small><noframes id='DXCNc'>

              <tfoot id='DXCNc'></tfoot>
                <bdo id='DXCNc'></bdo><ul id='DXCNc'></ul>
                  <tbody id='DXCNc'></tbody>

                • <legend id='DXCNc'><style id='DXCNc'><dir id='DXCNc'><q id='DXCNc'></q></dir></style></legend>
                  本文介绍了如何在 SELECT FROM 语句中使用表类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这个问题或多或少与this

                  在包头中:
                  声明了以下行类型:

                  In the package header :
                  Declared the following row type:

                    TYPE exch_row IS RECORD(
                      currency_cd VARCHAR2(9),
                      exch_rt_eur NUMBER,
                      exch_rt_usd NUMBER);
                  


                  而这个表类型:


                  And this table type:

                    TYPE exch_tbl IS TABLE OF exch_row INDEX BY BINARY_INTEGER;
                  


                  添加了一个变量:


                  Added a variable:

                  exch_rt exch_tbl;
                  


                  在包体中:
                  用一些数据填充这个表变量.


                  In the package body:
                  Fill this table variable with some data.


                  在包体中的一个过程中:
                  我想使用以下语句:


                  In a procedure in the package body:
                  I want to use the following statement:

                  CURSOR c0 IS
                    SELECT i.*, rt.exch_rt_eur, rt.exch_rt_usd
                    FROM item i, exch_rt rt
                    WHERE i.currency = rt.exchange_cd
                  


                  如何在 Oracle 中执行此操作?


                  How to do this in Oracle ?

                  注意事项

                  实际上我正在寻找 MSSQL 中的表变量"解决方案:

                  Actually I'm looking for the 'Table Variable' solution in MSSQL:

                  DECLARE @exch_tbl TABLE
                  (
                    currency_cd VARCHAR(9),
                    exch_rt_eur NUMBER,
                    exch_rt_usd NUMBER)
                  )
                  

                  并在我的 StoredProcedure 中使用这个表变量.

                  And use this Table Variable inside my StoredProcedure.

                  推荐答案

                  在 SQL 中,您只能使用在模式级别(而不是在包或过程级别)定义的表类型,不能使用按表索引(关联数组)在模式级别定义.所以 - 你必须像这样定义嵌套表

                  In SQL you may only use table type which is defined at schema level (not at package or procedure level), and index-by table (associative array) cannot be defined at schema level. So - you have to define nested table like this

                  create type exch_row as object (
                      currency_cd VARCHAR2(9),
                      exch_rt_eur NUMBER,
                      exch_rt_usd NUMBER);
                  
                  create type exch_tbl as table of exch_row;
                  

                  然后你可以在 SQL 中使用 TABLE 操作符,例如:

                  And then you can use it in SQL with TABLE operator, for example:

                  declare
                     l_row     exch_row;
                     exch_rt   exch_tbl;
                  begin
                     l_row := exch_row('PLN', 100, 100);
                     exch_rt  := exch_tbl(l_row);
                  
                     for r in (select i.*
                                 from item i, TABLE(exch_rt) rt
                                where i.currency = rt.currency_cd) loop
                        -- your code here
                     end loop;
                  end;
                  /
                  

                  这篇关于如何在 SELECT FROM 语句中使用表类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  SQL - Inserting a row and returning primary key(SQL - 插入一行并返回主键)
                  How to get Top 5 records in SqLite?(如何获得 Sqlite 中的前 5 条记录?)
                  SQL Server SELECT where any column contains #39;x#39;(SQL Server SELECT,其中任何列包含“x)
                  Default row order in SELECT query - SQL Server 2008 vs SQL 2012(SELECT 查询中的默认行顺序 - SQL Server 2008 与 SQL 2012)
                  Using a Variable in OPENROWSET Query(在 OPENROWSET 查询中使用变量)
                  Return number from Oracle Select statement after parsing date(解析日期后从 Oracle Select 语句返回编号)

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

                  <tfoot id='atIua'></tfoot>
                      <tbody id='atIua'></tbody>

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

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