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.

Zugriff auf PL/SQL - Procedures aus Java

Empfohlene Antworten

Veröffentlicht

Hi!

Ich sitze zur Zeit an einem Projekt, an dem ich aus Java auf Stored Procedures in Oracle ( PL/SQL ) zugreifen muss. Diese StoredProcedures schreiben dann die Daten in die Tabellen.

Wie funktioniert der Aufruf bzw. die Parameterübergabe? Funktionierts überhaupt generell?

Vielen Dank

oanes

Hallo,

A Java stored procedure or function requires that the library unit of the Java classes implementing it already be present in the database. Using the Greeting library unit example in the previous section, the following call specification DDL publishes the method Greeting.Hello() as a Java stored function:

CREATE FUNCTION MYHELLO(NAME VARCHAR2) RETURN VARCHAR2

AS LANGUAGE JAVA NAME

'Greeting.Hello(java.lang.String) return java.lang.String';

The DDL maps the Java methods, parameter types and return types to the SQL counterparts. To the users, the Java stored function has the same calling syntax as any other PL/SQL stored functions. Users can call the Java stored procedures the same way they call any PL/SQL stored procedures. Figure 6-5 depicts the runtime environment of a stored function.

Wenig Zeit, aber so muss es gehen.

Gibt noch eine Grafik zu dem Ablauf...

Gruesse

Denise

Ich kann mit diesem Beitrag leider nur wenig anfangen. Was sind Java Stored Procedures? Ich möchte lediglich aus Java mit JDBC eine PL/SQL - Stored Procedure aufrufen und die Parameter( z.B. Name, Vorname,...) übergeben, welche die PL/SQL - Prozedur dann in die Tabelle schreiben soll.

Geht´s vielleicht auch auf Deutsch?

Danke

oanes

:confused:

Hi,

also, du weisst auch nicht was du willst.

Du fragst nach:

Hi!

Ich sitze zur Zeit an einem Projekt, an dem ich aus Java auf Stored Procedures in Oracle ( PL/SQL ) zugreifen muss. Diese StoredProcedures schreiben dann die Daten in die Tabellen.

Wie funktioniert der Aufruf bzw. die Parameterübergabe? Funktionierts überhaupt generell?

Vielen Dank

oanes

und wenn die Antwort sich an die exakte Fragestellung sich richtet...

Man kann sich nicht mit Java und Oracle ohne Englisch befassen.

Tipp: www.google.com

und suche dann doch mal ne deutsche Seite.

Denise

Ich danke dir für die Mühe. Hab aber noch ne Frage!

Hab eine Tabelle in Oracle 9i erstellt:

create table test( g_id number(2) primary key not null,

g_pdffile blob,

g_xmlfile blob);

in der neben der ID eine PDF- und eine XML-Datei gespeichert werden soll.

Wie kann ich denn nun die Tabelle füllen? Wie kann ich die Datei angeben?

Vielen Dank

oanes

Hi !

Zu deiner ersten Frage hier ein kleiner Beispiel-Code, mit dem man aus Java heraus eine Stored Procedure starten kann. Diese erwartet einen numerischen Input-Parameter und liefert einen numerischen Wert zurück:

		long returnID = -1;

		String sql = new String ("begin myPackage.myProcedure (?, ?); end;");

		CallableStatement procinout = connection.prepareCall (sql);

		procinout.registerOutParameter (1, Types.NUMERIC);

		procinout.setLong (2, master_cid);

		procinout.execute ();

		returnID = procinout.getLong (1);

		procinout.close();

Und hier ein Beispiel zum Füllen eines LOB Feldes per Java ("conn" ist die DB Connection):
	PreparedStatement pStmt = conn.prepareStatement

				("update myTable "  +

				 "   set content = ?"  +

				 " where id = "   + idOfDocument );

	FileInputStream in   = new FileInputStream (sFilePath + sFileName);

	BufferedInputStream bIn = new BufferedInputStream (in);

	pStmt.setBinaryStream (1, bIn, (int)in.available());


	pStmt.execute();

	pStmt.close();

	in.close();

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.