Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PL/SQL Array an eine Unterprozedur übergeben

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich habe mir ein Array (Oder wie man das auch immer nennt in PL/SQL) wiefolgt deklariert:

TYPE meinArray IS TABLE OF NUMBER

INDEX BY BINARY_INTEGER;

varMeinArray meinArray; -- Also hier ist die Deklaration einer Variablen

Im laufe meine Codes wird das Array mit Werten befüllt (Menge ist nicht fest definiert).

Dieses Array möchte ich nun zur Weiterverarbeitung an eine Unterprozedur übergeben.

Also etwa so:

meine_Prozedur(varMeinArray);

Und die Prozedur hat folgenden Kopf:

CREATE OR REPLACE PROCEDURE meine_Prozedur(

meinArray in NUMBER)

is

[...]

Wenn ich nun Compiliere bekomme ich die Fehlermeldung, dass die Anzahl der übergebenen Argumente nicht stimmt.

Frage: wie an welcher Stelle übergebe ich das Array korrekt an meine Prozedur?

Gruß

Gany

Und die Prozedur hat folgenden Kopf:

CREATE OR REPLACE PROCEDURE meine_Prozedur(

meinArray in NUMBER)

is

Gruß

Gany

Hi,

also ich bin mir nicht ganz sicher aber müßte da nicht in

ungefähr so etws stehen

CREATE OR REPLACE PROCEDURE meine_Prozedur(pMeinArray in meinArray)

is 

Du willst ja keine Number übergeben sondern dein Array

  • Autor
Hi,

also ich bin mir nicht ganz sicher aber müßte da nicht in

ungefähr so etws stehen

CREATE OR REPLACE PROCEDURE meine_Prozedur(pMeinArray in meinArray)

is 

Du willst ja keine Number übergeben sondern dein Array

:( Er sagt, dass der Typ von meinArray in der Prozedur deklariert werden muss :confused: Wie mach ich das denn schon wieder?

Hallo zusammen.

Ich glaube in Deinem Fall würde ich den Parameter gar nicht übergeben, sondern als globale Variable in Deinem Package deklarieren.

Ansonsten müsstest du zumindest die Type-Deklarierung global in dem Package machen, hier bin ich mir aber nicht so sicher...

Es kommt auch darauf an, von wo du die Prozedur aufrufen willst: Innerhalb des Packages oder außerhalb...

Gruss, Axl

  • Autor
Hallo zusammen.

Ich glaube in Deinem Fall würde ich den Parameter gar nicht übergeben, sondern als globale Variable in Deinem Package deklarieren.

Ansonsten müsstest du zumindest die Type-Deklarierung global in dem Package machen, hier bin ich mir aber nicht so sicher...

Es kommt auch darauf an, von wo du die Prozedur aufrufen willst: Innerhalb des Packages oder außerhalb...

Gruss, Axl

Package?

Davon weiß ich

a) nichts

B) darf ich keine eigenen erstellen (:()

Gibts da wirklich keine andere Möglichkeit?

Gruß

Gany

As Parameters

You can declare PL/SQL tables as the formal parameters of functions and procedures. That way, you can pass PL/SQL tables to stored subprograms and from one subprogram to another. In the following example, you declare PL/SQL tables as the formal parameters of two packaged procedures:

PACKAGE emp_actions IS

TYPE EnameTabTyp IS TABLE OF emp.ename%TYPE

INDEX BY BINARY_INTEGER;

TYPE SalTabTyp IS TABLE OF emp.sal%TYPE

INDEX BY BINARY_INTEGER;

...

PROCEDURE hire_batch (ename_tab IN EnameTabTyp,

sal_tab IN SalTabTyp, ...);

PROCEDURE log_names (ename_tab IN EnameTabTyp);

END emp_actions;

To define the behavior of formal parameters, you use parameter modes. The OUT and IN OUT modes let you return values to the caller of a subprogram when you exit. If you exit successfully, PL/SQL assigns values to the actual parameters. However, if you exit with an unhandled exception, PL/SQL does not assign values to the actual parameters.

Quelle

Jetzt besteht nur noch ein Problem. Wo wird der Typ erstellt wenn nicht in einem Päckchen ? Ich forsche weiter :)

Probier es mal mit

CREATE OR REPLACE TYPE <typname> AS TABLE OF <datentyp>

evtl. muss der Zusatz "INDEX BY BINARY_INTEGER" noch dazu.

Hab das ganze aber noch nicht überprüft und weiss nicht, ab welcher ORACLE-Version das geht / gehen sollte ...

Gruss, Axl

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.