tailieunhanh - Oracle Built−in Packages- P72

Oracle Built−in Packages- P72: Ah, for the good old days of Version of PL /SQL! Life was so simple then. No stored procedures or functions and certainly no packages. You had your set of built−in functions, like SUBSTR and TO_DATE. You had the IF statement and various kinds of loops. With these tools at hand, you built your batch−processing scripts for execution in SQL*Plus, and you coded your triggers in SQL*Forms , and you went home at night content with a good day's work done. | Appendix A What s on the Companion Disk fileID strbuffer VARCHAR2 100 mynum NUMBER BEGIN fileID tmp R fileID strbuffer mynum TO_NUMBER strbuffer END When GET_LINE attempts to read past the end of the file the NO_DATA_FOUND exception is raised. This is the same exception that is raised when you a execute an implicit SELECT INTO cursor that returns no rows or b reference an undefined row of a PL SQL nested in PL SQL8 table. If you are performing more than one of these operations in the same PL SQL block remember that this same exception can be caused by very different parts of your program. Writing to Files In contrast to the simplicity of reading from a file UTL_FILE offers a number of different procedures you can use to write to a file Puts a piece of data string number or date into a file in the current line. Puts a newline or line termination character into the file at the current position. Puts a string into a file followed by a platform-specific line termination character. Puts up to five strings out to the file in a format based on a template string similar to the printf function in C. You can use these procedures only if you have opened your file with modes W or A if you opened the file for read-only the runtime engine will raise the exception. Starting with Oracle the maximum size of a file string is 32K the limit for earlier versions is 1023 bytes. If you have longer strings you must break them up into individual lines perhaps using a special continuation character to notify a post-processor to recombine those lines. The procedure The PUT procedure puts data out to the specified open file. Here s the header for this procedure PROCEDURE file IN buffer OUT VARCHAR2 Parameters are summarized in the following table. Parameter Description file The file