• <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 中的表中返回行类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                  How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                  Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                  Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                  Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                  Reset Sequence in oracle 11g(oracle 11g 中的重置序列)

                      • <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>