假设我有一个表和一个接受表行类型的一个参数的过程:
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 中以行类型文字作为参数调用过程?
发布评论