Hi,
my table "deltakelse" looks like this:
CREATE TABLE DELTAKELSE (
gulekort Smallint,
rodekort Smallint,
scoringer Smallint,
kampid Smallint NOT NULL,
spillerid Smallint NOT NULL,
CONSTRAINT PN_DELTAKELSE PRIMARY KEY (
kampid,
spillerid
)
where I want to make a function that returns the sum value of all inserts that are made to the attribute "scoringer" and then list (with a select quiry after) top 5 scores(scoringer).
This is my solution.. and the function is created but with compilation error:
create or replace function SisteTopScore is
cursor cGetScore is
select distinct scoringer from (
select spillerid, sum(scoringer) scoringer
from deltakelse where spillerid=spillerid
group by spillerid;
)
order by scoringer desc;
l_score number;
l_cnt number :=0;
begin
open cGetScore;
loop
fetch cGetScore into l_score;
l_cnt:=l_cnt+1;
exit when cGetScore%notfound or l_cnt=5;
end loop;
close cGetScore;
if l_cnt<5 then
l_score:=1;
end if;
return (l_score);
end;
/
And when I run my select it returns this error:ORA-06575: Package or function SISTETOPSCORE is in an invalid state.
probarly because of the function with compilation error. How can I make this work? pls advice.
my table "deltakelse" looks like this:
CREATE TABLE DELTAKELSE (
gulekort Smallint,
rodekort Smallint,
scoringer Smallint,
kampid Smallint NOT NULL,
spillerid Smallint NOT NULL,
CONSTRAINT PN_DELTAKELSE PRIMARY KEY (
kampid,
spillerid
)
where I want to make a function that returns the sum value of all inserts that are made to the attribute "scoringer" and then list (with a select quiry after) top 5 scores(scoringer).
This is my solution.. and the function is created but with compilation error:
create or replace function SisteTopScore is
cursor cGetScore is
select distinct scoringer from (
select spillerid, sum(scoringer) scoringer
from deltakelse where spillerid=spillerid
group by spillerid;
)
order by scoringer desc;
l_score number;
l_cnt number :=0;
begin
open cGetScore;
loop
fetch cGetScore into l_score;
l_cnt:=l_cnt+1;
exit when cGetScore%notfound or l_cnt=5;
end loop;
close cGetScore;
if l_cnt<5 then
l_score:=1;
end if;
return (l_score);
end;
/
And when I run my select it returns this error:ORA-06575: Package or function SISTETOPSCORE is in an invalid state.
probarly because of the function with compilation error. How can I make this work? pls advice.