12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Oracle</strong> Product-Specific Packages8.4 <strong>Oracle</strong> Product-Specific Packages<strong>Oracle</strong> and various <strong>Oracle</strong> tools are supplied with product-specific packages thatdefine application programming interfaces (APIs) you can call from PL/<strong>SQL</strong>, <strong>SQL</strong>,Java, or other programming environments. This topic includes a summary of twowidely used packages and a list of the most common packages with a briefdescription.See Also:■PL/<strong>SQL</strong> Packages and Types Reference for information on and usageof product-specific packages.About the DBMS_OUTPUT PackagePackage DBMS_OUTPUT enables you to display output from PL/<strong>SQL</strong> blocks,subprograms, packages, and triggers. The package is especially useful for displayingPL/<strong>SQL</strong> debugging information. The procedure PUT_LINE outputs information to abuffer that can be read by another trigger, procedure, or package. You display theinformation by calling the procedure GET_LINE or by setting SERVEROUTPUT ON in<strong>SQL</strong>*Plus. See Inputting and Outputting Data with PL/<strong>SQL</strong>.Example 8–2 shows how to display output from a PL/<strong>SQL</strong> block.Example 8–2Using PUT_LINE in the DBMS_OUTPUT Package-- set server output to ON to display output from DBMS_OUTPUTSET SERVEROUTPUT ONBEGINDBMS_OUTPUT.PUT_LINE('These are the tables that ' || USER || ' owns:');FOR item IN (SELECT table_name FROM user_tables)LOOPDBMS_OUTPUT.PUT_LINE(item.table_name);END LOOP;END;/About the UTL_FILE PackagePackage UTL_FILE lets PL/<strong>SQL</strong> programs read and write operating system (OS) textfiles. It provides a restricted version of standard OS stream file I/O, including open,put, get, and close operations.When you want to read or write a text file, you call the function FOPEN, which returnsa file handle for use in subsequent procedure calls. For example, the procedure PUT_LINE writes a text string and line terminator to an open file, and the procedure GET_LINE reads a line of text from an open file into an output buffer.Common <strong>Oracle</strong> Supplied PackagesTable 8–1 provides a list of the common PL/<strong>SQL</strong> packages included with <strong>Oracle</strong>Database.Table 8–1Package NameDBMS_ALERTSummary of <strong>Oracle</strong> Supplied PL/<strong>SQL</strong> PackagesDBMS_APPLICATION_INFODescriptionProvides support for the asynchronous notification ofdatabase events.Lets you register an application name with the databasefor auditing or performance tracking purposes.Subprograms and Packages: Usage Information 8-5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!