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

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

        <legend id='vnEHs'><style id='vnEHs'><dir id='vnEHs'><q id='vnEHs'></q></dir></style></legend>

        <tfoot id='vnEHs'></tfoot>

      1. 如何做一个函数来从 pl/sql 中的表中返回行类型?

        how to do a function to return row type from a table in pl/sql?(如何做一个函数来从 pl/sql 中的表中返回行类型?)

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

            • <bdo id='ZshkF'></bdo><ul id='ZshkF'></ul>

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

                <tbody id='ZshkF'></tbody>
              <tfoot id='ZshkF'></tfoot>
              <legend id='ZshkF'><style id='ZshkF'><dir id='ZshkF'><q id='ZshkF'></q></dir></style></legend>
                  本文介绍了如何做一个函数来从 pl/sql 中的表中返回行类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了这个函数,但是当我执行它时它返回一个错误!

                  I made this function but it return an error when i execute it!

                  create or replace function get_accounts
                  (Acc_id in Account1.account_id%Type)
                  return account1%rowtype
                  as
                  l_cust_record account1%rowtype;
                  begin
                  select * into l_cust_record from account1
                  where account_id=Acc_id;
                  return(l_cust_record);
                  end;
                  /
                  

                  推荐答案

                  Oracle 设置:

                  CREATE TABLE account1 (
                   account_id INT,
                   name       VARCHAR2(20)
                  );
                  
                  INSERT INTO account1 VALUES ( 1, 'Bob' );
                  
                  CREATE OR REPLACE FUNCTION get_accounts(
                    Acc_id IN Account1.account_id%TYPE
                  ) RETURN account1%ROWTYPE
                  AS
                    l_cust_record account1%ROWTYPE;
                  BEGIN
                    SELECT *
                    INTO   l_cust_record
                    FROM   account1
                    WHERE  account_id = Acc_id;
                  
                    RETURN l_cust_record;
                  END;
                  /
                  

                  PL/SQL 块:

                  DECLARE
                    r_acct ACCOUNT1%ROWTYPE;
                  BEGIN
                    r_acct := get_accounts( 1 );
                    DBMS_OUTPUT.PUT_LINE( r_acct.name );
                  END;
                  /
                  

                  输出:

                  Bob
                  

                  这篇关于如何做一个函数来从 pl/sql 中的表中返回行类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  How to select the first row for each group in MySQL?(如何在MySQL中为每个组选择第一行?)
                  MySQL - Fetching lowest value(MySQL - 获取最低值)
                  Add and link mysql libraries in a cmakelist.txt(在 cmakelist.txt 中添加和链接 mysql 库)
                  What is a good database design (schema) for a attendance database?(考勤数据库的良好数据库设计(架构)是什么?)

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

                          <tbody id='maEAt'></tbody>
                        <legend id='maEAt'><style id='maEAt'><dir id='maEAt'><q id='maEAt'></q></dir></style></legend>

                          <bdo id='maEAt'></bdo><ul id='maEAt'></ul>
                        • <tfoot id='maEAt'></tfoot>

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