Skip to Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Expert

Q:

24-29.

You see the following results:

SQL> @isopen.tst
Who closed my file?

In other words, even though the file is actually open, UTL_FILE acts as if it is closed. How to explain this strange behavior? Simple: the UTL_FILE.IS_OPEN function is not all that it appears to be. This program does not (as of Oracle8i Release 8.1, in any case) actually check with the operating system concerning the status of this file. It merely checks the value of the id field of the UTL_FILE.FILE_TYPE record (in the above block, fid); if that field is NOT NULL, the file is deemed to be open.

Q:

24-30.

This is a trick, and a tricky question. There really isn’t a way to get around the maximum-length limitation in UTL_FILE (1023 bytes prior to 8.0.5, 32K afterwards—at which point this idea will probably become irrelevant). Instead, you can write out chunks of the string within the allowable size, and then tack on a “continuation character” that indicates the line is continued and needs to be merged.

Here is one possible implementation that allows you to specify the continuation character and also the maximum allowable line size:

 /* Filename on web page: putline.sp */ CREATE OR REPLACE PROCEDURE put_line (file_in IN UTL_FILE.FILE_TYPE, line_in IN VARCHAR2, continchar_in IN VARCHAR2 := '-', max_line_size_in IN INTEGER := 1023) IS v_line VARCHAR2(32767); v_linelen CONSTANT INTEGER := LENGTH (line); v_start ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Oracle Database 12c PL/SQL Advanced Programming Techniques

Oracle Database 12c PL/SQL Advanced Programming Techniques

Michael McLaughlin, John Harper

Publisher Resources

ISBN: 9781449324070Errata Page