从子类型初始化对象
Initializing an object from subtype
我需要从子类型 B 创建并初始化一个对象,超类型 A 在 PL/SQL:
create or replace
TYPE "A" as object{
school_category varchar(10);
}
create or replace
TYPE "B" UNDER A {
school_name varchar(10);
school_ranking INTEGER;
}
现在,我 运行 下面的代码:
Declare
i_B B;
BEGIN
i_B := B('name_sample', 12, A('elementary'));
END;
我遇到以下错误:
PLS-00306: wrong number or types of arguments in call to 'B'
非常感谢你在这方面的帮助。非常感谢。
试试这个代码:-
Create Or Replace Type Atest As Object
(
School_Category Varchar2(10)
);
create or replace Type Btest Under Atest (
school_name varchar2(10),
School_Ranking number
);
DECLARE
var2 Btest;
BEGIN
var2 := Btest('Good','MySchool',2);
Dbms_Output.Put_Line(var2. School_Category);
Dbms_Output.Put_Line(var2. school_name);
Dbms_Output.Put_Line(var2. School_Ranking);
End;
或者
Create Or Replace Type Atest As Object
(
School_Category Varchar2(10)
);
create or replace Type Btest as Object (
school_name varchar2(10),
School_Ranking number,
School_Categ Atest
);
Declare
iobj Btest;
Begin
iobj:=Btest(school_name=>'MYSCHOOL',School_Ranking=>2,School_Categ=>Atest(School_Category=>'GOOD'));
Dbms_Output.Put_Line(Iobj.School_Name);
Dbms_Output.Put_Line(Iobj.School_Ranking);
end;
我需要从子类型 B 创建并初始化一个对象,超类型 A 在 PL/SQL:
create or replace
TYPE "A" as object{
school_category varchar(10);
}
create or replace
TYPE "B" UNDER A {
school_name varchar(10);
school_ranking INTEGER;
}
现在,我 运行 下面的代码:
Declare
i_B B;
BEGIN
i_B := B('name_sample', 12, A('elementary'));
END;
我遇到以下错误:
PLS-00306: wrong number or types of arguments in call to 'B'
非常感谢你在这方面的帮助。非常感谢。
试试这个代码:-
Create Or Replace Type Atest As Object
(
School_Category Varchar2(10)
);
create or replace Type Btest Under Atest (
school_name varchar2(10),
School_Ranking number
);
DECLARE
var2 Btest;
BEGIN
var2 := Btest('Good','MySchool',2);
Dbms_Output.Put_Line(var2. School_Category);
Dbms_Output.Put_Line(var2. school_name);
Dbms_Output.Put_Line(var2. School_Ranking);
End;
或者
Create Or Replace Type Atest As Object
(
School_Category Varchar2(10)
);
create or replace Type Btest as Object (
school_name varchar2(10),
School_Ranking number,
School_Categ Atest
);
Declare
iobj Btest;
Begin
iobj:=Btest(school_name=>'MYSCHOOL',School_Ranking=>2,School_Categ=>Atest(School_Category=>'GOOD'));
Dbms_Output.Put_Line(Iobj.School_Name);
Dbms_Output.Put_Line(Iobj.School_Ranking);
end;