Errata

Oracle PL/SQL Programming

Errata for Oracle PL/SQL Programming

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 15
2nd paragraph, "Improved Datatype Support"

The data types INTEGER, INT and SMALLINT are not 32-bit integers, but subtypes of NUMBER with a max. precision of 38 digits.
See http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/datatypes.htm#sthref685 .

Anonymous  Jun 18, 2009 
Printed Page 17
Execution section of anonymous PL/SQL block after 1st paragraph

The line of code is:

my_string := regexp_replace(my_string, phone_number_pattern, '(\1) \2');

The line of code should be:

my_string := regexp_replace(my_string, phone_number_pattern, '(\1) \2 \3');

The replacement string in the call to REGEXP_REPLACE needs one more matching pattern, in order for the output to match what is shown in the text after the anonymous block

"The output from this code block is:

999-888-7777
The phone number 999-888-7777 is not ours.

Anonymous  Dec 03, 2008 
Printed Page 71
About 10 lines from the bottom

The text says: 'The notion of the time interval is yet another feature introduced in
Oracle Database 10g;'
It seems to me it is introduced in Oracle 9i Database.

Anonymous   
Printed Page 71
Middle of page

Datetime literals (available since Oracle Database 10g Release 2) should also be mentioned (see http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements003.htm). The last paragraph on the page may need to be reformulated accordingly or removed.

This also applies to the 5th edition of the book

Anonymous  Sep 21, 2011 
Printed Page 119
Last sentence before the heading 'Loop Labels'

cursor_name.column_name should be record_name.column_name

Anonymous   
Printed Page 132
Code at top of page

Error numbers assigned to CONSTANT variables are not used. I believe the intent was to use the
variable names (instead of hard coding the error numbers) in the subsequent PRAGMA declrations. So
PRAGMA_EXCEPTION_INIT(exc_too_young, -20001); should be PRAGMA_EXCEPTION_INIT(exc_too_young,
en_too_young); and PRAGMA_EXCEPTION_INIT(exc_sal_too_low, -20002); should be
PRAGMA_EXCEPTION_INIT(exc_sal_too_low, en_sal_too_low);

Anonymous   
Printed Page 175
last paragraph

I am referring to third edition published September 2002.

The last sentence of the last paragraph on page 175 seems incomplete. The paragraph discusses the
rowidtochar function and how it converts a binary value of type rowid to a string of type varchar2.
Then it states that the format of the return string is BBBBBBBB.RRRR.FFFF where each section
represents a number in hexidecimal format and then ends with this sentence:

All three numbers are in hexidecimal format; for example:
11/14/1994 1988 2018

and with that the paragraph simply ends. It appears to be incomplete and I don't find any reference
to this in the other errata that has been published about this book.

Anonymous   
Printed Page 186
at the bottom, when there is the example from the file cast.sql

In the file cast.sql there is the following code:

DECLARE
scifi_favorites authors_t
:= authors_t ('Sheri S. Tepper', 'Orson Scott Card', 'Gene Wolfe');
BEGIN
DBMS_OUTPUT.put_line ('I recommend that you read books by:');

FOR rec IN (SELECT column_value favs
FROM TABLE (CAST (scifi_favorites AS names_t))
UNION
SELECT NAME
FROM favorite_authors)
LOOP
DBMS_OUTPUT.put_line (rec.favs);
END LOOP;
END;

with the following explanation from the book (page 187 at the top):
"... I cast the PL/SQL nested table (local and not visible to the SQL engine) as a type of nested table known in the database. ..."
It's talking about the bit of code <CAST (scifi_favorites AS names_t)>, where a authors_t nested table has been casted as a names_t nested table.
But the authors_t type is not local, indeed it was previously created as <CREATE TYPE authors_t AS TABLE OF VARCHAR2 (100);>, hence the pl/sql block works even without casting as follows:

DECLARE
scifi_favorites authors_t
:= authors_t ('Sheri S. Tepper', 'Orson Scott Card', 'Gene Wolfe');
BEGIN
DBMS_OUTPUT.put_line ('I recommend that you read books by:');
FOR rec IN (SELECT column_value favs
FROM TABLE (scifi_favorites)
UNION
SELECT NAME
FROM favorite_authors)
LOOP
DBMS_OUTPUT.put_line (rec.favs);
END LOOP;
END;

davide  Feb 15, 2009 
Printed Page 204
5th paragraph - sample output ("The output is:")

The final line of output is listed as:
".....Hi there!....."

This output is for:
DBMS_OUTPUT.PUT_LINE( TRIM(x) );

which is supposed to have a default trim character of the space. If that's the case, then the
output should be:
".....Hithere!....."

Anonymous   
Printed Page 211
Last paragraph

I know this doesn't qualify as errata, but I think it's important. The sample regular expression
used to demonstrate greediness is:

.*,

The problem is that the period (.) is never explained to mean any valid character. It confused me,
but I was able to look it up easily elsewhere.

Anonymous   
Printed Page 259
Tip, Suggestion, Note section - smaller print

The internal representation of the timestamp and timezone should be 2002-02-06 20:00:00:00:00
-0:00, and not => 2002-02-06 20:00:00:00:00 -5:00.

Since this is in UTC time.

Anonymous   
Printed Page 263
The CAST example

Oracle PL/SQL Programming, Fourth Edition by Steven Feuerstein with Bill
Pribyl

(263) The CAST example's second DBMS_OUTPUT function the "a" variable
name needs to be a "b".

Anonymous  Jan 21, 2009 
Printed Page 289
line -6~-4

1 select to_timestamp_tz('02-APR-07 08.45.58.270000 AM -07:00') as tz
2 , cast( to_timestamp_tz('02-APR-07 08.45.58.270000 AM -07:00')
3 as timestamp with local time zone) as lcl_tz
4 , to_timestamp_tz('02-APR-07 08.45.58.270000 AM US/EASTERN') as tz
5 , cast( to_timestamp_tz('02-APR-07 08.45.58.270000 AM US/EASTERN')
6 as timestamp with local time zone) as lcl_tz
7* from dual
DWP1@edwdev SQL+> /

02-APR-07 08.45.58.270000000 AM -07:00
02-APR-07 10.45.58.270000 AM
02-APR-07 08.45.58.270000000 AM US/EASTERN
02-APR-07 07.45.58.270000 AM

Anonymous   
Printed Page 353
3rd paragraph

Says, "When using a nested tables ..."
Should say, "When using a nested table ..."

Anonymous   
Printed Page 354
Code block, lines 24, 27, & 28

Calls to function "descriptions" should be "description". This occurs on code lines 24, 27, & 28.

Anonymous   
Printed Page 373
1st paragraph under "Nested Table Multiset Operations"

Line 3 reads, "...nested tables (and only, for time being, to nested tables."

It should read, ""...nested tables (and only, for time being, to nested tables)."

Missing the closing parenthesis.

Anonymous   
Printed Page 376
next to last line

Its not obvious from my code whether the temperature 45 degrees is assigned to the point (X:1, Y:2, Z:3) or to (X:3, Y:2, Z:1).

I found myself asking, "Ok, which one is it?"

One more sentence would have made it clearer.

Dave Sanders  Dec 01, 2009 
Printed Page 401
2nd paragraph

",which is less than the 32,767 bytes supported by VARCHAR2 and RAW"

should be:

",which is less than the 4,000 bytes supported by VARCHAR2 and RAW."

Arnaud Fargues  Aug 02, 2012 
Printed Page 413
2nd paragraph under "The XMLType Type" header

2nd sentence is "Staring with Oracle9i ..." It should be "Starting with Oracle9i ..."

Anonymous   
Printed Page 434
3rd paragraph

Under the title "Record-based updates":

"...The following example INSERTS a row into the books table ... "

should read

"...The following example UPDATES a row ... "

Anonymous   
Printed Page 439
Paragraph preceding figure 14-3

Reads, "If I needed to insert 100 rows ..."
Should read, "If I needed to update 100 rows ..."

Anonymous   
Printed Page 458
3rd paragraph (Codesection Package Body)

Procedure Putline inserts into recently created table logtab (p. 457). However, this
insert does not match the table. Columns machine and program is missing.

The "file on web" points to log.pkg which does exist, but rather uses log81tab and so
on. Here are the missing columns (but this code does not work anyway)
It seems that there is an update of the code in progress and only half of it has made
it all the way.

Either of the code fragments work.

Anonymous   
Printed Page 477
3rd line

It seems to me that
'RETURN level_out;'
should be changed in
'RETURN retval;'

Anonymous   
Printed Page 477
3rd paragraph

line 27 of the FUNCTION jealousy_level returns a value (level_out) that is not declared in the
function

Anonymous   
Printed Page 478
3rd line under 'Declaring cursors in packages'

It seems to me that 'not within a particular procedure or function in the package'
better be left away. It seems to me it suggests cursors can't be declared in
procedures or functions.

Anonymous   
Printed Page 485
Tip section at top of page

The URL reference to Gennick's "Open Cursors" article is no longer valid.

Anonymous   
Printed Page 491
Example cursor code

The cursor is declared as "major_polluters_cur", but then referenced as "major_polluters".

Anonymous   
Printed Page 493
2nd code example at top of page

The "l_transportation" variable is referenced without first being declared.

Anonymous   
Printed Page 493
Last paragraph

Limiting Rows Retrieved with BULK COLLECT
For 8i have to use %NOTFOUND as COUNT never gets set to zero.
Guess this is a feature of LIMIT in 8i that was corrected for 9i.

Anonymous  Jun 25, 2009 
Printed Page 498
3rd paragraph

The OF list of the FOR UPDATE may not just for document.

I ran into problems with it. There is an old code in our applicaton to update the
column; it failed to update the column not in the OF list couple of month ago. It
started to work again with the columns being put in the list. It may be an Oracle
bug or config problem. Anyway, there is no harm in putting the columns in the list.

Anonymous   
Printed Page 498
3rd cursor

FOR UPDATE OF husband_config.max_proastination_allowed;
->
FOR UPDATE OF hc.max_proastination_allowed;

Anonymous  Sep 14, 2009 
Printed Page 529
Code in Method 3

I think two lines of code in the Execute Immediate example in the above method are in
the wrong order.

The book says:
execute immediate
'select last_name, salary from employee
where department_id = :dept_id'
using 10
into l_last_name, l_salary;

which doesn't work when copied into code. I think it should read:
execute immediate
'select last_name, salary from employee
where department_id = :dept_id'
into l_last_name, l_salary
using 10;

which does.

Anonymous   
Printed Page 566
3ed Paragraph - More Managable

a 1000-line program or five individual 2000-line programs...
should read
a 1000-line program or five individual 200-line programs...

Dave Sanders  Dec 01, 2009 
Printed Page 612
In the sql where the function is first illustrated in the from clause

In line 6 of the SQL, the "AS pet_nt", presumably an alias after the function call, causes Oracle
to tell me that I'm missing a right parenthesis. When I take this alias out of the code, it works
perfectly as written without other modifications.

I'm running against Oracle 10.2.0.1.0, and the error happened both in Toad and in SQL Plus.

Anonymous   
Printed Page 642
Code example on the bottom

The 2 lines in the loop:
EXIT WHEN book_info.bytitle_cur%NOTFOUND;
FETCH book_info.bytitle_cur INTO onebook;
are in the wrong order, they should read:
FETCH book_info.bytitle_cur INTO onebook;
EXIT WHEN book_info.bytitle_cur%NOTFOUND;

Anonymous   
Printed Page 644
Code example on the top of the page

The order of the lines inside the loop:
EXIT WHEN ...
FETCH personnel ...
should be changed - first fetch next check if the record was fetched.
The way it currently is the last row fetched by the cursor will be processed twice. See also error
on page 642.

Anonymous   
Printed Page 649
code of givebonus2.sp

In line 14

l_row := l_array.FIRST;

has to be

l_row := l_employees.FIRST;

Anonymous   
Printed Page 999
middle

Page 999 says about the TREAT function "[TREAT] will return either the downcasted object or NULL - but not an error". That is true if TREAT is used in SQL, but if TREAT is used in PL/SQL and the object is not of the required type, TREAT does indeed raise an error.

See http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjbas.htm#i479093

"If p is a person who is not a student, or if p is NULL, TREAT returns NULL in SQL or, in PL/SQL, raises an exception."

Anonymous   
Printed Page 999
middle

Page 999 says about the TREAT function "[TREAT] will return either the downcasted object or NULL - but not an error". That is true if TREAT is used in SQL, but if TREAT is used in PL/SQL and the object is not of the required type, TREAT does indeed raise an error.

See http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjbas.htm#i479093

"If p is a person who is not a student, or if p is NULL, TREAT returns NULL in SQL or, in PL/SQL, raises an exception."

Anonymous  May 16, 2008 
Printed Page 1021
First sentence

"The alternative to MAP is an ORDER member function, which compares two METHODS: SELF, and another object..."
should be
"The alternative to MAP is an ORDER member function, which compares two objects: SELF, and another object..."

Anonymous