I am trying to display all the values in an object but it give me 'must be declared' error.
I tried the code below but still giving me same error.
declare
outN mytype;
begin
outN:= get_data();
dbms_output.put_line(outN.toString);
-- tried this as well
dbms_output.put_line(outN.ID);
dbms_output.put_line(outN.G);
dbms_output.put_line(outN.GES);
dbms_output.put_line(outN.CC);
dbms_output.put_line(outN.RR);
end;
And my object is:
create or replace TYPE "mytype"
AS OBJECT
(
"ID" NUMBER(10),
"G" NUMBER(10),
"GES" VARCHAR(100 BYTE),
"CC" NUMBER(10),
"RR" VARCHAR(100 BYTE)
);
Errors:
Error report - ORA-06550: line 5, column 38: PLS-00302: component 'ID' must be declared ORA-06550: line 5, column 7: PL/SQL: Statement ignored ORA-06550: line 6, column 38: PLS-00302: component 'G' must be declared ORA-06550: line 6, column 7: PL/SQL: Statement ignored ORA-06550: line 7, column 38: PLS-00302: component 'GES' must be declared ORA-06550: line 7, column 7: PL/SQL: Statement ignored ORA-06550: line 8, column 38: PLS-00302: component 'CC' must be declared ORA-06550: line 8, column 7: PL/SQL: Statement ignored ORA-06550: line 9, column 38: PLS-00302: component 'RR' must be declared ORA-06550: line 9, column 7: PL/SQL: Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error.
Another one:
Error report - ORA-06550: line 5, column 38: PLS-00302: component 'TOSTRING' must be declared ORA-06550: line 5, column 7: PL/SQL: Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
get_data is just a function that return the result of a select statement (returns db rows)
toString? I don't see an attribute (or method) of typemytypein its definition. In any case, the first error will be thrown at the name of the type. You declared it as"mytype". In Oracle, when you use double-quotes, you are saying that you want case-sensitive identifiers. By default Oracle is not case sensitive; it will automatically convertmytypein your code block toMYTYPE, which will not match"mytype". Get in the habit of not using double-quoted identifiers, they only bring trouble. The alternative is in the declarations section to use double quotes.get_data(), also? There is a call to it in your code, but you haven't shown us what it is. ALSO: If you need help, you will have to include the exact error message(s) in your posts. Right now, the typeMYTYPEis not declared (lower-case"mytype"is, which is different), but you will likely get more errors - tell us exactly what they are."mytype"but you reference it without double-quotes, you will not get to the "undeclared components", you will get the errorPLS-00201: identifier 'MYTYPE' must be declaredfirst.MYTYPE? Which may still exist in your schema (or a schema you have privileges to)? What do you get if youselect * from ALL_TYPES where UPPER(type_name) = 'MYTYPE'?