Oracle Database 11g: Advanced PL/SQL5 - 17Copyright © 2008, Oracle. All rights reserved.5 - 17Executing the External Procedure1.Create and compile the external procedure in 3GL.2.Link the external procedure with the shared library at theoperating system level.3.Create an alias library schema object to map to theoperating system’s shared library.4.Grant execute privileges on the library.5.Publish the external C procedure by creating the PL/SQLsubprogram unit specification, which references the aliaslibrary.6.Execute the PL/SQL subprogram that invokes the externalprocedure.Executing the External Procedure: ExampleHere is a simple example of invoking the external routine:BEGINDBMS_OUTPUT.PUT_LINE(tax_amt(100));END;You can call the function in a cursorFORloop or in any location where a PL/SQL function callis allowed:DECLARECURSOR cur_orders ISSELECT order_id, order_totalFROMorders;v_taxNUMBER(8,2);BEGINFOR order_record IN cur_ordersLOOPv_tax :=tax_amt(order_record.order_total);DBMS_OUTPUT.PUT_LINE('Total tax: ' || v_tax);END LOOP;END;
Oracle Database 11g: Advanced PL/SQL5 - 18Copyright © 2008, Oracle. All rights reserved.5 - 18Java: OverviewThe Oracle database can store Java classes and Java source,which:•Are stored in the database as procedures, functions, ortriggers•Run inside the database•Manipulate dataJava: OverviewThe Oracle database can store Java classes (.classfiles) and Java source code (.javafiles),which are stored in the database as procedures, functions, or triggers. These classes canmanipulate data but cannot display graphical user interface (GUI) elements such as AbstractWindow Toolkit (AWT) or Swing components. Running Java inside the database helps theseJava classes to be called many times and manipulate large amounts of data without theprocessing and network overhead that comes with running on the client machine.You must write these named blocks, and then define them by using theloadjavacommand orthe SQLCREATE FUNCTION,CREATE PROCEDURE,CREATE TRIGGER, orCREATEPACKAGEstatements.
Oracle Database 11g: Advanced PL/SQL5 - 19Copyright © 2008, Oracle. All rights reserved.5 - 19Calling a Java Class Method by Using PL/SQLlibunitsJava class/home/java/bin/Agent.class13JavaVirtualMachine2CREATEJAVA4Calling a Java Class Method by Using PL/SQLTheloadjavacommand-line utility uploads the Java binaries and resources into a system-generated database table. It then uses theCREATE JAVAstatement to load the Java files intothe RDBMS libunits. You can upload the Java files from file systems, Java IDEs, intranets, orthe Internet.When theCREATE JAVAstatement is invoked, the Java Virtual Machine library manager onthe server loads the Java binaries and resources from the localBFILEs orLOBcolumns into theRDBMS libunits. Libunits can be considered analogous to the DLLs written in C, although theymap one-to-one with Java classes, whereas DLLs can contain multiple routines.
Upload your study docs or become a
Course Hero member to access this document
Upload your study docs or become a
Course Hero member to access this document
End of preview. Want to read all 744 pages?
Upload your study docs or become a
Course Hero member to access this document
Term
Fall
Professor
N/A
Tags
Oracle Database, Advanced PL SQL