PLS-00488: object “string” must be a type or subtype - but it is a type











up vote
2
down vote

favorite
1












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!










share|improve this question
























  • 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















up vote
2
down vote

favorite
1












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!










share|improve this question
























  • 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













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





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!










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 17:21

























asked Nov 8 at 3:57









Pedro

455




455












  • 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


















  • 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
















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












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:




  1. The object type is not instantiated correctly in the query.

  2. 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.






share|improve this answer























  • 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













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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:




  1. The object type is not instantiated correctly in the query.

  2. 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.






share|improve this answer























  • 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

















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:




  1. The object type is not instantiated correctly in the query.

  2. 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.






share|improve this answer























  • 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















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:




  1. The object type is not instantiated correctly in the query.

  2. 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.






share|improve this answer















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:




  1. The object type is not instantiated correctly in the query.

  2. 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.







share|improve this answer














share|improve this answer



share|improve this answer








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




















  • 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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini