[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

[PL/SQL] Select fra cursor i PL/SQL-funktion?



Jeg vil gerne skrive en PL/SQL-funktion der kan udvælge en optimal
værdi fra et udvalg af værdier.  Tanken er at skrive en funktion der
kan kaldes omtrent således:

   select *
   from   Tabel_A
   where  ID = Udvælg (select ID from Tabel_B where Betingelse);

Jeg vil altså kunne bruge »select« til at udvælge en liste der skal
kigges på.

Blandt de udvalgte, vil jeg så vælge det ID der er knyttet flest
datapunkter til:

   function Udvælg (Mængde Mængdetype) return NUMBER is
      cursor Rang is select   ID,
                              Count (Dato) Antal
                     from     Tabel_A
                     where    ID in (Mængde)
                     group by ID
                     order by Antal desc;
      R Rang%RowType;
   begin
      open Rang;
      fetch Rang into R;
      return R.ID;
   end Udvælg;

Mit problem er at jeg ikke er sikker på hvordan jeg bør overføre min
mængde af ID'er til funktionen, således at jeg kan bruge den i en
»select«-sætning.

Mit umiddelbare bud var at bruge en »ref cursor«-type, men så får jeg
at vide at den kan jeg ikke bruge i min »select«-sætning i funktionen.

God fornøjelse,

Jacob
-- 
"Being an absolute ruler today was not as simple as people
 thought.  At least, it was not simple if your ambitions
 included being an absolute ruler tomorrow."


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2009-09-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *