PLS-00488: object “string” must be a type or subtype - but it is a type
up vote
2
down vote
favorite
I am trying to do build a sentence using a UDT, as follows:
CREATE OR REPLACE TYPE fv_group as object(
fv NUMBER,
group_number INTEGER
);
/
CREATE OR REPLACE TYPE fv_group_array IS VARRAY(100) OF fv_group;
CREATE OR REPLACE TYPE fv_grouping AS OBJECT (
fv_and_group fv_group_array,
MEMBER PROCEDURE insert_groupby(FV NUMBER),
MEMBER FUNCTION which_group(FV NUMBER) RETURN INTEGER
);
/
CREATE OR REPLACE TYPE BODY fv_grouping as
MEMBER PROCEDURE insert_groupby(FV NUMBER) IS
g fv_group;
BEGIN
IF fv < 15 THEN
g := fv_group(fv,1);
ELSE
g := fv_group(fv,2);
END IF;
fv_and_group.extend(1);
fv_and_group(fv_and_group.last) := g;
END;
MEMBER FUNCTION which_group(FV NUMBER) RETURN INTEGER IS
feature NUMBER;
BEGIN
FOR i IN 1..fv_and_group.count LOOP
feature := fv_and_group(i).fv;
IF fv_and_group(i).fv = fv THEN
RETURN fv_and_group(i).group_number;
END IF;
END LOOP;
RETURN 0;
END;
END;
/
The representation I need is:
DECLARE
obj fv_grouping;
BEGIN
SELECT :obj.which_group(gb.fv), count(*)
FROM (
SELECT :obj.insert_groupby(c.fv, 6, 3)
from cophir
) gb
GROUP BY :obj.which_group(gb.fv);
END;
/
The procedure insert_groupby inserts each value of the cophir table into a varray, wich holds its values and the corresponding group.
After the varray is loaded with all values and their corresponding group, I want to group them. Is it possible, to do it in a query?
Thanks in advance!
sql oracle plsql oracle12c user-defined-types
add a comment |
up vote
2
down vote
favorite
I am trying to do build a sentence using a UDT, as follows:
CREATE OR REPLACE TYPE fv_group as object(
fv NUMBER,
group_number INTEGER
);
/
CREATE OR REPLACE TYPE fv_group_array IS VARRAY(100) OF fv_group;
CREATE OR REPLACE TYPE fv_grouping AS OBJECT (
fv_and_group fv_group_array,
MEMBER PROCEDURE insert_groupby(FV NUMBER),
MEMBER FUNCTION which_group(FV NUMBER) RETURN INTEGER
);
/
CREATE OR REPLACE TYPE BODY fv_grouping as
MEMBER PROCEDURE insert_groupby(FV NUMBER) IS
g fv_group;
BEGIN
IF fv < 15 THEN
g := fv_group(fv,1);
ELSE
g := fv_group(fv,2);
END IF;
fv_and_group.extend(1);
fv_and_group(fv_and_group.last) := g;
END;
MEMBER FUNCTION which_group(FV NUMBER) RETURN INTEGER IS
feature NUMBER;
BEGIN
FOR i IN 1..fv_and_group.count LOOP
feature := fv_and_group(i).fv;
IF fv_and_group(i).fv = fv THEN
RETURN fv_and_group(i).group_number;
END IF;
END LOOP;
RETURN 0;
END;
END;
/
The representation I need is:
DECLARE
obj fv_grouping;
BEGIN
SELECT :obj.which_group(gb.fv), count(*)
FROM (
SELECT :obj.insert_groupby(c.fv, 6, 3)
from cophir
) gb
GROUP BY :obj.which_group(gb.fv);
END;
/
The procedure insert_groupby inserts each value of the cophir table into a varray, wich holds its values and the corresponding group.
After the varray is loaded with all values and their corresponding group, I want to group them. Is it possible, to do it in a query?
Thanks in advance!
sql oracle plsql oracle12c user-defined-types
in your exampleinsert_groupby
has only 2 parameters, but you pass 3 values
– hotfix
Nov 8 at 7:29
@hotfix - true but that's not the cause of the PLS-00488 error.
– APC
Nov 8 at 8:28
even if the type with the namegrouping
is allowed, it causes the future issues as being a keyword as @APC emphasized. The Database primarily assumes it as a keyword instead of being a type. I suppose it's a bug, and should be fixed for Oracle DB( the issue still exists for version 12.1.0.2.0 ).
– Barbaros Özhan
Nov 8 at 10:36
Indeed, there is a issue ... I'd like to use the type in the query ... is it possible by any means?
– Pedro
Nov 8 at 17:36
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am trying to do build a sentence using a UDT, as follows:
CREATE OR REPLACE TYPE fv_group as object(
fv NUMBER,
group_number INTEGER
);
/
CREATE OR REPLACE TYPE fv_group_array IS VARRAY(100) OF fv_group;
CREATE OR REPLACE TYPE fv_grouping AS OBJECT (
fv_and_group fv_group_array,
MEMBER PROCEDURE insert_groupby(FV NUMBER),
MEMBER FUNCTION which_group(FV NUMBER) RETURN INTEGER
);
/
CREATE OR REPLACE TYPE BODY fv_grouping as
MEMBER PROCEDURE insert_groupby(FV NUMBER) IS
g fv_group;
BEGIN
IF fv < 15 THEN
g := fv_group(fv,1);
ELSE
g := fv_group(fv,2);
END IF;
fv_and_group.extend(1);
fv_and_group(fv_and_group.last) := g;
END;
MEMBER FUNCTION which_group(FV NUMBER) RETURN INTEGER IS
feature NUMBER;
BEGIN
FOR i IN 1..fv_and_group.count LOOP
feature := fv_and_group(i).fv;
IF fv_and_group(i).fv = fv THEN
RETURN fv_and_group(i).group_number;
END IF;
END LOOP;
RETURN 0;
END;
END;
/
The representation I need is:
DECLARE
obj fv_grouping;
BEGIN
SELECT :obj.which_group(gb.fv), count(*)
FROM (
SELECT :obj.insert_groupby(c.fv, 6, 3)
from cophir
) gb
GROUP BY :obj.which_group(gb.fv);
END;
/
The procedure insert_groupby inserts each value of the cophir table into a varray, wich holds its values and the corresponding group.
After the varray is loaded with all values and their corresponding group, I want to group them. Is it possible, to do it in a query?
Thanks in advance!
sql oracle plsql oracle12c user-defined-types
I am trying to do build a sentence using a UDT, as follows:
CREATE OR REPLACE TYPE fv_group as object(
fv NUMBER,
group_number INTEGER
);
/
CREATE OR REPLACE TYPE fv_group_array IS VARRAY(100) OF fv_group;
CREATE OR REPLACE TYPE fv_grouping AS OBJECT (
fv_and_group fv_group_array,
MEMBER PROCEDURE insert_groupby(FV NUMBER),
MEMBER FUNCTION which_group(FV NUMBER) RETURN INTEGER
);
/
CREATE OR REPLACE TYPE BODY fv_grouping as
MEMBER PROCEDURE insert_groupby(FV NUMBER) IS
g fv_group;
BEGIN
IF fv < 15 THEN
g := fv_group(fv,1);
ELSE
g := fv_group(fv,2);
END IF;
fv_and_group.extend(1);
fv_and_group(fv_and_group.last) := g;
END;
MEMBER FUNCTION which_group(FV NUMBER) RETURN INTEGER IS
feature NUMBER;
BEGIN
FOR i IN 1..fv_and_group.count LOOP
feature := fv_and_group(i).fv;
IF fv_and_group(i).fv = fv THEN
RETURN fv_and_group(i).group_number;
END IF;
END LOOP;
RETURN 0;
END;
END;
/
The representation I need is:
DECLARE
obj fv_grouping;
BEGIN
SELECT :obj.which_group(gb.fv), count(*)
FROM (
SELECT :obj.insert_groupby(c.fv, 6, 3)
from cophir
) gb
GROUP BY :obj.which_group(gb.fv);
END;
/
The procedure insert_groupby inserts each value of the cophir table into a varray, wich holds its values and the corresponding group.
After the varray is loaded with all values and their corresponding group, I want to group them. Is it possible, to do it in a query?
Thanks in advance!
sql oracle plsql oracle12c user-defined-types
sql oracle plsql oracle12c user-defined-types
edited Nov 8 at 17:21
asked Nov 8 at 3:57
Pedro
455
455
in your exampleinsert_groupby
has only 2 parameters, but you pass 3 values
– hotfix
Nov 8 at 7:29
@hotfix - true but that's not the cause of the PLS-00488 error.
– APC
Nov 8 at 8:28
even if the type with the namegrouping
is allowed, it causes the future issues as being a keyword as @APC emphasized. The Database primarily assumes it as a keyword instead of being a type. I suppose it's a bug, and should be fixed for Oracle DB( the issue still exists for version 12.1.0.2.0 ).
– Barbaros Özhan
Nov 8 at 10:36
Indeed, there is a issue ... I'd like to use the type in the query ... is it possible by any means?
– Pedro
Nov 8 at 17:36
add a comment |
in your exampleinsert_groupby
has only 2 parameters, but you pass 3 values
– hotfix
Nov 8 at 7:29
@hotfix - true but that's not the cause of the PLS-00488 error.
– APC
Nov 8 at 8:28
even if the type with the namegrouping
is allowed, it causes the future issues as being a keyword as @APC emphasized. The Database primarily assumes it as a keyword instead of being a type. I suppose it's a bug, and should be fixed for Oracle DB( the issue still exists for version 12.1.0.2.0 ).
– Barbaros Özhan
Nov 8 at 10:36
Indeed, there is a issue ... I'd like to use the type in the query ... is it possible by any means?
– Pedro
Nov 8 at 17:36
in your example
insert_groupby
has only 2 parameters, but you pass 3 values– hotfix
Nov 8 at 7:29
in your example
insert_groupby
has only 2 parameters, but you pass 3 values– hotfix
Nov 8 at 7:29
@hotfix - true but that's not the cause of the PLS-00488 error.
– APC
Nov 8 at 8:28
@hotfix - true but that's not the cause of the PLS-00488 error.
– APC
Nov 8 at 8:28
even if the type with the name
grouping
is allowed, it causes the future issues as being a keyword as @APC emphasized. The Database primarily assumes it as a keyword instead of being a type. I suppose it's a bug, and should be fixed for Oracle DB( the issue still exists for version 12.1.0.2.0 ).– Barbaros Özhan
Nov 8 at 10:36
even if the type with the name
grouping
is allowed, it causes the future issues as being a keyword as @APC emphasized. The Database primarily assumes it as a keyword instead of being a type. I suppose it's a bug, and should be fixed for Oracle DB( the issue still exists for version 12.1.0.2.0 ).– Barbaros Özhan
Nov 8 at 10:36
Indeed, there is a issue ... I'd like to use the type in the query ... is it possible by any means?
– Pedro
Nov 8 at 17:36
Indeed, there is a issue ... I'd like to use the type in the query ... is it possible by any means?
– Pedro
Nov 8 at 17:36
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
grouping is a type. What is wrong?
GROUPING is an Oracle keyword. If you re-name your type to say FV_GROUPING you will solve the PLS-00488. Which will leave you free to address all the other syntax errors in your code:
- The object type is not instantiated correctly in the query.
- SELECT statements embedded in PL/SQL must select into a variable which matches the projection of the query.
Not sure what your code is trying to achieve, but this version of your code runs:
DECLARE
obj fv_grouping;
BEGIN
SELECT fv_grouping(cast(collect(fv_group(fv, 3)) as fv_group_array))
into obj
from cophir;
dbms_output.put_line(obj.which_group(2)) ;
END;
/
This uses COLLECT to gather the fv_group
objects into an fv_group_array
instance which can be used to instantiate fv_grouping
and populate the obj
variable.
Thanks ... I do need to call the functions of the UDT in the select-from-where-gb clause too. How could I make it? Is it possible?
– Pedro
Nov 8 at 14:27
You'd have to wrap my query above in an outer query and reference the member functions there. If you cannot figure it out, please edit your question to include more details.
– APC
Nov 8 at 14:31
I have edited the question ... hope you can help. I need to populate a VArray not only one object. I need to do it in a query, like I have represented in the question. Do u think it is possible?
– Pedro
Nov 8 at 17:23
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
grouping is a type. What is wrong?
GROUPING is an Oracle keyword. If you re-name your type to say FV_GROUPING you will solve the PLS-00488. Which will leave you free to address all the other syntax errors in your code:
- The object type is not instantiated correctly in the query.
- SELECT statements embedded in PL/SQL must select into a variable which matches the projection of the query.
Not sure what your code is trying to achieve, but this version of your code runs:
DECLARE
obj fv_grouping;
BEGIN
SELECT fv_grouping(cast(collect(fv_group(fv, 3)) as fv_group_array))
into obj
from cophir;
dbms_output.put_line(obj.which_group(2)) ;
END;
/
This uses COLLECT to gather the fv_group
objects into an fv_group_array
instance which can be used to instantiate fv_grouping
and populate the obj
variable.
Thanks ... I do need to call the functions of the UDT in the select-from-where-gb clause too. How could I make it? Is it possible?
– Pedro
Nov 8 at 14:27
You'd have to wrap my query above in an outer query and reference the member functions there. If you cannot figure it out, please edit your question to include more details.
– APC
Nov 8 at 14:31
I have edited the question ... hope you can help. I need to populate a VArray not only one object. I need to do it in a query, like I have represented in the question. Do u think it is possible?
– Pedro
Nov 8 at 17:23
add a comment |
up vote
2
down vote
grouping is a type. What is wrong?
GROUPING is an Oracle keyword. If you re-name your type to say FV_GROUPING you will solve the PLS-00488. Which will leave you free to address all the other syntax errors in your code:
- The object type is not instantiated correctly in the query.
- SELECT statements embedded in PL/SQL must select into a variable which matches the projection of the query.
Not sure what your code is trying to achieve, but this version of your code runs:
DECLARE
obj fv_grouping;
BEGIN
SELECT fv_grouping(cast(collect(fv_group(fv, 3)) as fv_group_array))
into obj
from cophir;
dbms_output.put_line(obj.which_group(2)) ;
END;
/
This uses COLLECT to gather the fv_group
objects into an fv_group_array
instance which can be used to instantiate fv_grouping
and populate the obj
variable.
Thanks ... I do need to call the functions of the UDT in the select-from-where-gb clause too. How could I make it? Is it possible?
– Pedro
Nov 8 at 14:27
You'd have to wrap my query above in an outer query and reference the member functions there. If you cannot figure it out, please edit your question to include more details.
– APC
Nov 8 at 14:31
I have edited the question ... hope you can help. I need to populate a VArray not only one object. I need to do it in a query, like I have represented in the question. Do u think it is possible?
– Pedro
Nov 8 at 17:23
add a comment |
up vote
2
down vote
up vote
2
down vote
grouping is a type. What is wrong?
GROUPING is an Oracle keyword. If you re-name your type to say FV_GROUPING you will solve the PLS-00488. Which will leave you free to address all the other syntax errors in your code:
- The object type is not instantiated correctly in the query.
- SELECT statements embedded in PL/SQL must select into a variable which matches the projection of the query.
Not sure what your code is trying to achieve, but this version of your code runs:
DECLARE
obj fv_grouping;
BEGIN
SELECT fv_grouping(cast(collect(fv_group(fv, 3)) as fv_group_array))
into obj
from cophir;
dbms_output.put_line(obj.which_group(2)) ;
END;
/
This uses COLLECT to gather the fv_group
objects into an fv_group_array
instance which can be used to instantiate fv_grouping
and populate the obj
variable.
grouping is a type. What is wrong?
GROUPING is an Oracle keyword. If you re-name your type to say FV_GROUPING you will solve the PLS-00488. Which will leave you free to address all the other syntax errors in your code:
- The object type is not instantiated correctly in the query.
- SELECT statements embedded in PL/SQL must select into a variable which matches the projection of the query.
Not sure what your code is trying to achieve, but this version of your code runs:
DECLARE
obj fv_grouping;
BEGIN
SELECT fv_grouping(cast(collect(fv_group(fv, 3)) as fv_group_array))
into obj
from cophir;
dbms_output.put_line(obj.which_group(2)) ;
END;
/
This uses COLLECT to gather the fv_group
objects into an fv_group_array
instance which can be used to instantiate fv_grouping
and populate the obj
variable.
edited Nov 8 at 8:25
answered Nov 8 at 7:53
APC
116k15114227
116k15114227
Thanks ... I do need to call the functions of the UDT in the select-from-where-gb clause too. How could I make it? Is it possible?
– Pedro
Nov 8 at 14:27
You'd have to wrap my query above in an outer query and reference the member functions there. If you cannot figure it out, please edit your question to include more details.
– APC
Nov 8 at 14:31
I have edited the question ... hope you can help. I need to populate a VArray not only one object. I need to do it in a query, like I have represented in the question. Do u think it is possible?
– Pedro
Nov 8 at 17:23
add a comment |
Thanks ... I do need to call the functions of the UDT in the select-from-where-gb clause too. How could I make it? Is it possible?
– Pedro
Nov 8 at 14:27
You'd have to wrap my query above in an outer query and reference the member functions there. If you cannot figure it out, please edit your question to include more details.
– APC
Nov 8 at 14:31
I have edited the question ... hope you can help. I need to populate a VArray not only one object. I need to do it in a query, like I have represented in the question. Do u think it is possible?
– Pedro
Nov 8 at 17:23
Thanks ... I do need to call the functions of the UDT in the select-from-where-gb clause too. How could I make it? Is it possible?
– Pedro
Nov 8 at 14:27
Thanks ... I do need to call the functions of the UDT in the select-from-where-gb clause too. How could I make it? Is it possible?
– Pedro
Nov 8 at 14:27
You'd have to wrap my query above in an outer query and reference the member functions there. If you cannot figure it out, please edit your question to include more details.
– APC
Nov 8 at 14:31
You'd have to wrap my query above in an outer query and reference the member functions there. If you cannot figure it out, please edit your question to include more details.
– APC
Nov 8 at 14:31
I have edited the question ... hope you can help. I need to populate a VArray not only one object. I need to do it in a query, like I have represented in the question. Do u think it is possible?
– Pedro
Nov 8 at 17:23
I have edited the question ... hope you can help. I need to populate a VArray not only one object. I need to do it in a query, like I have represented in the question. Do u think it is possible?
– Pedro
Nov 8 at 17:23
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53201359%2fpls-00488-object-string-must-be-a-type-or-subtype-but-it-is-a-type%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
in your example
insert_groupby
has only 2 parameters, but you pass 3 values– hotfix
Nov 8 at 7:29
@hotfix - true but that's not the cause of the PLS-00488 error.
– APC
Nov 8 at 8:28
even if the type with the name
grouping
is allowed, it causes the future issues as being a keyword as @APC emphasized. The Database primarily assumes it as a keyword instead of being a type. I suppose it's a bug, and should be fixed for Oracle DB( the issue still exists for version 12.1.0.2.0 ).– Barbaros Özhan
Nov 8 at 10:36
Indeed, there is a issue ... I'd like to use the type in the query ... is it possible by any means?
– Pedro
Nov 8 at 17:36