SlideShare a Scribd company logo
Old Oracle Versions
Top 20 Gotchas

Jeffrey Kemp
AUSOUG Perth Conference, October 2012
Poll
• Oldest Oracle
database version
worked with
• Past 12 months
(approximately)
Database Versions & Extended Support
v7
v8
8i
9i
9iR2
10g
10gR2
11g
11gR2
2015

2010

2005

2000

1995

1992

12c
Disclaimer
The following is intended to outline the general product direction
way back in the distant past. It is intended for information purposes
only, and may not always be perfectly syntactically correct. It is not a
commitment to deliver any material, code, or functionality, and
should not be relied upon in making purchasing decisions (if you’re
thinking of buying 8i or 9i, you should probably get out from under
that rock). The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole
discretion of Oracle… who cares, give us the new features now!
“Be grateful for what you have...”
vs.
#20: insert from record type
INSERT INTO mytable
VALUES rec;
#20: insert from record type
INSERT INTO mytable
VALUES rec;
INSERT INTO mytable
(col1, col2, col3, …)
VALUES
(rec.col1, rec.col2, rec.col3, …);
#19: temporary tables
CREATE GLOBAL TEMPORARY TABLE t...
#19: temporary tables
BEGIN
TRUNCATE TABLE ordinary_tmp;
INSERT INTO ordinary_tmp ...;
-- etc…
END;
#18: error messages
EXCEPTION
DBMS_OUTPUT.put_line(
DBMS_UTILITY.format_error_backtrace
);
RAISE;
END;
#18: error messages
EXCEPTION
DBMS_OUTPUT.put_line(
DBMS_UTILITY.format_error_backtrace
SQLERRM
);
RAISE;
END;
#17: queries on DBMS_RANDOM
SELECT DBMS_RANDOM.value FROM dual;
ORA-00600 internal error
http://www.angelfire.com/home/jasonvogel/oracle_plsql_random_number_generator.html
#16: TIMESTAMP & INTERVAL
the_exact_time TIMESTAMP
:= SYSTIMESTAMP;
#16: TIMESTAMP & INTERVAL
the_exact_time TIMESTAMP
:= SYSTIMESTAMP;
Java - timestamp.getTime()
(number of milliseconds since January 1, 1970, 00:00:00
GMT)
#15: DIRECTORY objects
CREATE DIRECTORY mydir AS '/usr/example';
#15: DIRECTORY objects
CREATE DIRECTORY mydir AS '/usr/example';
ALTER SYSTEM
SET UTL_FILE_DIR='/usr/example' SCOPE=SPFILE;
- restart database
f := utl_file.fopen( '/usr/example'
, 'myfile.txt'
, 'rw');
#14: SQL analytic functions
BEGIN
FOR r IN (
SELECT RANK(a)
OVER (PARTITION BY b
ORDER BY c) q
FROM t) LOOP ...
#14: SQL analytic functions
BEGIN
FOR r IN (
SELECT RANK(a)
OVER (PARTITION BY b
ORDER BY c) q
FROM t) LOOP ...
CREATE VIEW v AS
SELECT RANK(a) OVER (PARTITION BY b ORDER BY c) q FROM t;
BEGIN
FOR r IN (SELECT q FROM t) LOOP ...
(alternatively, use dynamic SQL instead)
Analytic functions were added in 8iR2, but they only work in plain SQL – PL/SQL embedded SQL didn’t use the same engine.

R2
#13: write BLOB to file
l_file := UTL_FILE.fopen
('BLOBS','MyImage.gif','w', 32767);
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer, TRUE);
l_pos := l_pos + l_amount;
END LOOP;

UTL_FILE.fclose(l_file);
#13: write BLOB to file
l_file := UTL_FILE.fopen
('BLOBS','MyImage.gif','w', 32767);

WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer, TRUE);
l_pos := l_pos + l_amount;
END LOOP;
UTL_FILE.fclose(l_file);
Java - http://www.oracle-base.com/articles/8i/export-blob.php
#12: external tables
CREATE TABLE t ... ORGANIZATION EXTERNAL
#12: external tables
CREATE TABLE t ... ORGANIZATION EXTERNAL
CREATE OR REPLACE VIEW diy$extfile AS
SELECT *
FROM TABLE(
CAST(read_file_into_array()
AS my_array_type)
);
(using UTL_FILE) - http://www.oracle-base.com/articles/8i/diydynamic-views.php
#11: XMLTYPE
CREATE TABLE t (myxml XMLTYPE);
#11: XMLTYPE
CREATE TABLE t (myxml XMLTYPE);
xmlparser.parse( v_parser
, 'C:emp.xml');
v_doc := xmlparser.getDocument
(v_parser);

http://www.oracle-base.com/articles/8i/parsexml-documents-8i.php
#10: NULL datatype conversion
SELECT null, null, null
FROM dual
UNION ALL
SELECT 'abc', 123, DATE '2012-01-01'
FROM dual;
ORA-01790: expression must have same datatype as
corresponding expression

?
#10: NULL datatype conversion
SELECT null, null, null
FROM dual
UNION ALL
SELECT 'abc', 123, DATE '2012-01-01'
FROM dual;
SELECT null, TO_NUMBER(null), TO_DATE(null)
FROM dual
UNION ALL
SELECT 'abc', 123, DATE '2012-01-01'
FROM dual;
vs.
#9: MERGE
MERGE INTO d
USING (SELECT * FROM src) s
ON (d.id = s.id)
WHEN MATCHED THEN
UPDATE d.a = s.a, d.b = s.b
WHERE s.a = 'x'
DELETE WHERE s.a = 'z'
WHEN NOT MATCHED THEN
INSERT (s.id, s.a, s.b)
WHERE s.b = 'y';
WHEN MATCHED and WHEN NOT MATCHED are optional*
* DELETE WHERE must be part of a WHEN MATCHED clause, however
#9: MERGE
MERGE INTO d
USING (SELECT * FROM src) s
ON (d.id = s.id)
WHEN MATCHED THEN
UPDATE d.a = s.a, d.b = s.b
WHERE s.a = 'x'
DELETE WHERE s.a = 'z'
WHEN NOT MATCHED THEN
INSERT (s.id, s.a, s.b)
WHERE s.b = 'y';
WHEN MATCHED and WHEN NOT MATCHED are mandatory
#9: MERGE
MERGE INTO d
USING (SELECT * FROM src) s
ON (d.id = s.id)
WHEN MATCHED THEN
UPDATE d.a = s.a, d.b = s.b
WHEN NOT MATCHED THEN
INSERT (s.id, s.a, s.b);
FOR s IN (SELECT * FROM src) LOOP
UPDATE d SET d.a = s.a, d.b = s.b WHERE d.id = s.id;
IF SQL%ROWCOUNT = 0 THEN
INSERT INTO d VALUES (s.id, s.a, s.b);
END IF;
END LOOP;
#8: FORALL on sparse array
FORALL i IN INDICES OF arr
INSERT INTO t (arr(i));
#8: FORALL on sparse array
FORALL i IN INDICES OF arr
INSERT INTO t (arr(i));
un-sparse that array, then…
FORALL i IN 1..arr.COUNT
INSERT INTO t (arr(i));
#7: UTL_MAIL
#7: UTL_SMTP
#6: string literals
v_sql := q'[SELECT q'{She said 'Hello'.}' FROM t]';
#6: string literals
v_sql := q'[SELECT q'{She said 'Hello'.}' FROM t]';
single-quotes-masquerading-as-double-quotes hell…

v_sql := 'SELECT ''She said ''''Hello''''.'' FROM t';
#5: Regular Expressions
• REGEXP_INSTR
• REGEXP_REPLACE
• REGEXP_SUBSTR
#5: Regular Expressions
• Try this homegrown solution:
http://phil-sqltips.blogspot.com.au/2009/06/regexpreplaceregexplike-for-oracle-9i.html

• Or just do it old-school – INSTR, SUBSTR,
LIKE, TRANSLATE, etc.
#4: PLS_INTEGER vs. BINARY_INTEGER

PLS_INTEGER = BINARY_INTEGER
#4: PLS_INTEGER vs. BINARY_INTEGER
• PLS_INTEGER uses native arithmetic = faster
• PLS_INTEGER
- overflow exception
• BINARY_INTEGER overflow
- no overflow exception*
* If a 9i BINARY_INTEGER operation overflows, no exception is raised if the result is being assigned to a NUMBER. In 10g, this is not true –
PLS_INTEGER and BINARY_INTEGER are identical, both raise an exception on overflow.
#3: DBMS_OUTPUT
Max size: unlimited
Line size: 32KB
#3: DBMS_OUTPUT
Max size: 1 million bytes*
Line size: 255 bytes

*default = 20,000 bytes
#2, #1, #0
• no PL/SQL conditional compilation
• no Recycle Bin for dropped tables
• no flashback table*

*NOTE: in my original presentation I claimed “no flashback query” in 9i, but this is incorrect.
(Thanks to Tom Kyte for the correction!)
Moral of the story?
• Use appropriate
features when available
• Be professional
• Keep old Oracle
documentation URLs
Images Attribution
http://4.bp.blogspot.com/-ib6RKHzuEaU/Tb4aaXaqYI/AAAAAAAANVk/s5RPjflt4hU/s1600/cadillac-car-wreck.jpg

http://images.brisbanetimes.com.au/2012/03/08/3109605/Women%20vote.jpg
http://i47.photobucket.com/albums/f189/captjeremy/ace_ventura_pet_detective_fake
_pict.jpg
http://rlv.zcache.com/vintage_business_mailman_mail_carrier_delivering_postcardp239921576489667584envli_400.jpg

http://technology.amis.nl/2006/04/04/back-to-the-future-oracle-41-vm-appliance/
Thank you

http://jeffkemponoracle.com

More Related Content

PDF
Building Maintainable Applications in Apex
PPTX
Why You Should Use TAPIs
KEY
Let's build a parser!
PDF
C++ for Java Developers (JavaZone 2017)
PDF
Just-In-Time Compiler in PHP 8
PDF
Being functional in PHP (DPC 2016)
KEY
SPL, not a bridge too far
PDF
perl course-in-mumbai
Building Maintainable Applications in Apex
Why You Should Use TAPIs
Let's build a parser!
C++ for Java Developers (JavaZone 2017)
Just-In-Time Compiler in PHP 8
Being functional in PHP (DPC 2016)
SPL, not a bridge too far
perl course-in-mumbai

What's hot (18)

PDF
Coding Guidelines - Crafting Clean Code
PDF
"How was it to switch from beautiful Perl to horrible JavaScript", Viktor Tur...
PDF
Functional Structures in PHP
PPTX
Creating own language made easy
PDF
JavaScript Functions
PDF
Melhorando sua API com DSLs
ODP
Back to basics - PHP_Codesniffer
PDF
Perl6 grammars
PDF
PHPSpec BDD Framework
PDF
I, For One, Welcome Our New Perl6 Overlords
PPTX
LinkedIn TBC JavaScript 100: Functions
PDF
Cli the other sapi pbc11
PDF
OOP and FP - Become a Better Programmer
PDF
Lambdas and Streams Master Class Part 2
PDF
Perl IO
PDF
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
PDF
Perl6 in-production
PDF
The Joy of Smartmatch
Coding Guidelines - Crafting Clean Code
"How was it to switch from beautiful Perl to horrible JavaScript", Viktor Tur...
Functional Structures in PHP
Creating own language made easy
JavaScript Functions
Melhorando sua API com DSLs
Back to basics - PHP_Codesniffer
Perl6 grammars
PHPSpec BDD Framework
I, For One, Welcome Our New Perl6 Overlords
LinkedIn TBC JavaScript 100: Functions
Cli the other sapi pbc11
OOP and FP - Become a Better Programmer
Lambdas and Streams Master Class Part 2
Perl IO
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Perl6 in-production
The Joy of Smartmatch
Ad

Viewers also liked (6)

PPTX
Učinkovitejše iskanje v Google
PDF
ScholarChip visitor_manager
PPTX
Nature Walk
PDF
Taking Human Error out of K12 Attendance Equation
PDF
See how technology can simplify your school.
PPTX
Single page App
Učinkovitejše iskanje v Google
ScholarChip visitor_manager
Nature Walk
Taking Human Error out of K12 Attendance Equation
See how technology can simplify your school.
Single page App
Ad

Similar to Old Oracle Versions (20)

PDF
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
PDF
Porting Oracle Applications to PostgreSQL
PDF
Oracle adapters for Ruby ORMs
ODP
PostgreSQL 8.4 TriLUG 2009-11-12
DOC
Oracle etl openworld
PDF
Exploring plsql new features best practices september 2013
PPTX
Oracle to Postgres Schema Migration Hustle
 
PPTX
PostgreSQL - It's kind've a nifty database
ODP
Porting Applications From Oracle To PostgreSQL
PPTX
Modern sql
PPTX
PDF
Whats new in_postgres_enterprise_db_20130124
 
PDF
Oracle 11G Development Training noida Delhi NCR
PPTX
Ein Expertenleitfaden für die Migration von Legacy-Datenbanken zu PostgreSQL
 
PPT
IEEE Day 2013 Oracle Database 12c: new features for developers
PDF
Stumbling stones when migrating from Oracle
 
PDF
20180420 hk-the powerofmysql8
PDF
Oracle 10g Database Administrator Implementation and Administration 2nd Editi...
PDF
Oracle 10g Database Administrator Implementation and Administration 2nd Editi...
PDF
Sql for dbaspresentation
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Porting Oracle Applications to PostgreSQL
Oracle adapters for Ruby ORMs
PostgreSQL 8.4 TriLUG 2009-11-12
Oracle etl openworld
Exploring plsql new features best practices september 2013
Oracle to Postgres Schema Migration Hustle
 
PostgreSQL - It's kind've a nifty database
Porting Applications From Oracle To PostgreSQL
Modern sql
Whats new in_postgres_enterprise_db_20130124
 
Oracle 11G Development Training noida Delhi NCR
Ein Expertenleitfaden für die Migration von Legacy-Datenbanken zu PostgreSQL
 
IEEE Day 2013 Oracle Database 12c: new features for developers
Stumbling stones when migrating from Oracle
 
20180420 hk-the powerofmysql8
Oracle 10g Database Administrator Implementation and Administration 2nd Editi...
Oracle 10g Database Administrator Implementation and Administration 2nd Editi...
Sql for dbaspresentation

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Spectroscopy.pptx food analysis technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation theory and applications.pdf
PDF
KodekX | Application Modernization Development
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Big Data Technologies - Introduction.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Network Security Unit 5.pdf for BCA BBA.
Spectroscopy.pptx food analysis technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation theory and applications.pdf
KodekX | Application Modernization Development
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Big Data Technologies - Introduction.pptx

Old Oracle Versions