如何在 PL/SQL 中以行类型文字作为参数调用过程?

编程入门 行业动态 更新时间:2024-10-28 20:21:01
本文介绍了如何在 PL/SQL 中以行类型文字作为参数调用过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设我有一个表和一个接受表行类型的一个参数的过程:

CREATE TABLE t (a NUMBER, b NUMBER);创建过程 p (x t%ROWTYPE) 是开始空值;结尾;

我可以使用 rowtype 文字调用该过程,即不显式创建 rowtype 变量(或至少不显式列出和分配它的每个字段)?以下两种方法都会产生以下错误:

p(1, 2);

p((1, 2));

PLS-00306:调用P"时的参数数量或类型错误

解决方案

您也可以从游标循环构造记录:

for r in (从双选 1, 2)环形p(r);结束循环;

不幸的是,PL/SQL 记录只是简单的结构,不像对象类型那样带有构造函数.(我希望他们这样做.)

Lets say I have a table and a procedure that accepts one argument of the tables rowtype:

CREATE TABLE t (a NUMBER, b NUMBER); CREATE PROCEDURE p (x t%ROWTYPE) IS BEGIN NULL; END;

Can I call that procedure using a rowtype literal, that is without explicitly creating a rowtype variable (or at least not explicitly listing and assigning every field of it)? The two following approaches both generate the below error:

p(1, 2);

p((1, 2));

PLS-00306: wrong number or types of arguments in call to 'P'

解决方案

You could also construct the record from a cursor loop:

for r in ( select 1, 2 from dual ) loop p(r); end loop;

Unfortunately PL/SQL records are just simple structures and don't come with constructors as object types do. (I wish they did.)

更多推荐

如何在 PL/SQL 中以行类型文字作为参数调用过程?

本文发布于:2023-07-22 13:32:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1187949.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中以   参数   过程   类型   文字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!