Frage

Also ich habe noch nie mit Stored Procedures und habe nicht viel von DB Erfahrung im Allgemeinen gearbeitet, und ich habe eine Aufgabe zugewiesen wurde, die erfordert ich ein Paket erstellen, und ich bin fest.

Mit SQL Developer, Ich versuche, ein Paket mit dem Namen erstellen JumpTo mit diesem Code ...


create or replace package JUMPTO is
  type t_locations is ref cursor;

  procedure procGetLocations(locations out t_locations);

end JUMPTO;

Wenn ich es laufen, es spuckt diesen PL / SQL-Code-Block ...


DECLARE
  LOCATIONS APPLICATION.JUMPTO.t_locations;
BEGIN

  JUMPTO.PROCGET_LOCATIONS(
    LOCATIONS => LOCATIONS
  );
  -- Modify the code to output the variable
  -- DBMS_OUTPUT.PUT_LINE('LOCATIONS = ' || LOCATIONS);
END;

Ein Tutorial Ich sagte, fand dort für die zweite Zeile den Kommentar zu nehmen. Ich habe versucht, mit und ohne Kommentar.

Wenn ich Hit "ok" Ich habe den Fehler bekommen ...


ORA-06550: line 2, column 32:
PLS-00302: component 'JUMPTO' must be declared
ORA-06550: line 2, column 13:
PL/SQL: item ignored
ORA-06550: line 6, column 18:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored
ORA-06512: at line 58

ich habe wirklich keine Ahnung, was los ist, ist das alles Neuland für mich. Ich habe versucht, einen Körper zu schaffen, das nur ein paar Sachen aus der Datenbank ausgewählt, aber nichts funktioniert so, wie es scheint, wie es sollte in meinem Kopf. Kann jemand mir dies einen Einblick in?

War es hilfreich?

Lösung

Zunächst einmal müssen Sie einen Paketkörper, zum Beispiel erklären:

create or replace package body JUMPTO is

  procedure procGetLocations(locations out t_locations)
  is
  begin
    locations := null; -- Need code here
  end;

end JUMPTO;

Um dies kompilieren müssen:

 DECLARE
     LOCATIONS JUMPTO.t_locations;
   BEGIN
     JUMPTO.PROCGETLOCATIONS(
       LOCATIONS => LOCATIONS
     );
   END;

Andere Tipps

Ein Oracle PL / SQL-Paket besteht aus 2 Teilen:

  • Ein Paket-Spezifikation (der öffentliche Teil, in dem global zugänglichen Konstanten, Funktionen, Prozeduren, Variablen, usw. aufgelistet sind).
  • Ein Paket Körper (wo der Code die Paket-Spezifikation zu implementieren befindet).

Ihr erstes Stück Code, das Paket Spezifikation deklariert ( JumpTo ). Sie erklärte einen Typ ( t_locations ) und ein Verfahren ( procGetLocations ), die keine Eingänge, sondern gibt eine Variable ( Orte ) vom Typ t_locations.

Sie zuerst das Paket spec kompilieren (wie du), dann kompilieren Sie das Paket Körper wie folgt:

create or replace package body JUMPTO is  
procedure procGetLocations(locations out t_locations) is  
begin    
locations := null; -- Your code goes here
end procGetLocations;
end JUMPTO;

Jetzt können Sie die Prozedur aufrufen procGetLocations in anderen PL / SQL-Blöcke (anonym oder nicht).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top