product-specific packagesthe oracle and different


Product-specific Packages

The Oracle and different Oracle tools are supplied with the product-specific packages which help you to build the PL/SQL-based applications. For illustration, the Oracle is supplied with a lot of utility packages, a few of that are highlighted below.

DBMS_STANDARD

The Package DBMS_STANDARD gives language facilities which help your application interact with the Oracle. For illustration, the procedure raise_application_error issue a user-defined error messages. In that way, you can report the errors to an application and evade returning the unhandled exceptions.

DBMS_ALERT

The Package DBMS_ALERT use the database triggers to alert an application when the definite database values change. The alerts are asynchronous (i.e., they operate separately of any timing mechanism) and transaction based. For illustration, a company may use this package to update the value of its investment portfolio as the new stock and bond quotes arrive.

DBMS_OUTPUT

The Package DBMS_OUTPUT enables you to display output from the PL/SQL subprograms and blocks, that makes it easier to test and debug them. The procedure put_ line results the information to the buffer in the SGA. You can display the information by calling the procedure get_line or by setting the SERVEROUTPUT ON in the SQL*Plus. For illustration, assume that you create the stored procedure which is as shown below:

CREATE PROCEDURE calc_payroll (payroll OUT NUMBER) AS

CURSOR c1 IS SELECT sal, comm FROM emp;

BEGIN

payroll := 0;

FOR c1rec IN c1 LOOP

c1rec.comm := NVL(c1rec.comm, 0);

payroll := payroll + c1rec.sal + c1rec.comm;

END LOOP;

/* Display debug info. */

DBMS_OUTPUT.PUT_LINE('Value of payroll: ' || TO_CHAR(payroll));

END;

Whenever you issue the commands below, the SQL*Plus display the value assigned by the procedure to the parameter payroll:

SQL> SET SERVEROUTPUT ON

SQL> VARIABLE num NUMBER

SQL> CALL calc_payroll(:num);

Value of payroll: 31225

DBMS_PIPE

The Package DBMS_PIPE allows various sessions to communicate over the named pipes. (A pipe is a region of memory used by one of the process to pass information to the other.) You can use the procedures pack_message & send_message to pack a message into the pipe, then it send to the other session in the similar instance.

At the other part of the pipe, you can use the procedures receive_message and unpack_message to receive and unpack the message. The Named pipes are helpful in many ways. For illustration, you can write the routines in C which allow an external servers to collect the information, then send it through pipes to the procedures stored in an Oracle database.

UTL_FILE

The Package UTL_FILE permits your PL/SQL programs to read & write operating system (OS) text files. It gives a restricted version of the standard OS stream file I/O, involving the open, put, get, and close operations. When you desire to read or write a text file, you call the function fopen that returns a file handle for use in consequent procedure calls. For illustration, the procedure put_line writes a text string and line terminator to an open file. The procedure get_line reads a line of the text from an open file into an output buffer.

The PL/SQL file I/O is accessible on both the client and server sides. Though, on the server side, the file access is constrained to those directories explicitly listed in the accessible directories list that is stored in the Oracle initialization file.

UTL_HTTP

The Package UTL_HTTP permits your PL/SQL programs to make hypertext transfer protocol (HTTP) callouts. It can recover data from the Internet or call Oracle Web Server cartridges. The package has 2 entry points, each of that accepts a uniform resource locator (URL) string, links the specified site, and returns the requested data, that is usually in the hypertext markup language (HTML) format.

Request for Solution File

Ask an Expert for Answer!!
PL-SQL Programming: product-specific packagesthe oracle and different
Reference No:- TGS0173014

Expected delivery within 24 Hours