100% found this document useful (4 votes)
71 views

Instant Download Modern Oracle Database Programming: Level Up Your Skill Set to Oracle’s Latest and Most Powerful Features in SQL, PL/SQL, and JSON 1st Edition Alex Nuijten PDF All Chapters

JSON

Uploaded by

dehenshigacp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
71 views

Instant Download Modern Oracle Database Programming: Level Up Your Skill Set to Oracle’s Latest and Most Powerful Features in SQL, PL/SQL, and JSON 1st Edition Alex Nuijten PDF All Chapters

JSON

Uploaded by

dehenshigacp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Download the Full Version of ebook for Fast Typing at ebookmass.

com

Modern Oracle Database Programming: Level Up Your


Skill Set to Oracle’s Latest and Most Powerful
Features in SQL, PL/SQL, and JSON 1st Edition Alex
Nuijten
https://ebookmass.com/product/modern-oracle-database-
programming-level-up-your-skill-set-to-oracles-latest-and-
most-powerful-features-in-sql-pl-sql-and-json-1st-edition-
alex-nuijten/

OR CLICK BUTTON

DOWNLOAD NOW

Download More ebook Instantly Today - Get Yours Now at ebookmass.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Modern Oracle Database Programming: Level Up Your Skill


Set to Oracle’s Latest and Most Powerful Features in SQL,
PL/SQL, and JSON 1st Edition Alex Nuijten
https://ebookmass.com/product/modern-oracle-database-programming-
level-up-your-skill-set-to-oracles-latest-and-most-powerful-features-
in-sql-pl-sql-and-json-1st-edition-alex-nuijten/
ebookmass.com

Oracle PL/SQL by Example, 6th Edition Benjamin Rosenzweig

https://ebookmass.com/product/oracle-pl-sql-by-example-6th-edition-
benjamin-rosenzweig/

ebookmass.com

OCA Oracle Database SQL Exam Guide (Exam 1Z0-071) 1st


Edition Steve O’Hearn

https://ebookmass.com/product/oca-oracle-database-sql-exam-guide-
exam-1z0-071-1st-edition-steve-ohearn/

ebookmass.com

Oracle Database Programming with Visual Basic.NET:


Concepts, Designs and Implementations Ying Bai

https://ebookmass.com/product/oracle-database-programming-with-visual-
basic-net-concepts-designs-and-implementations-ying-bai/

ebookmass.com
Oracle 12c: SQL 3rd Edition, (Ebook PDF)

https://ebookmass.com/product/oracle-12c-sql-3rd-edition-ebook-pdf/

ebookmass.com

Oracle Autonomous Database For Dummies®, 3rd Special


Edition Lawrence Miller

https://ebookmass.com/product/oracle-autonomous-database-for-
dummies-3rd-special-edition-lawrence-miller/

ebookmass.com

Python Programming and SQL: 10 Books in 1 - Supercharge


Your Career with Python Programming and SQL Andrew Reed

https://ebookmass.com/product/python-programming-and-sql-10-books-
in-1-supercharge-your-career-with-python-programming-and-sql-andrew-
reed/
ebookmass.com

Procedural Programming with PostgreSQL PL/pgSQL: Design


Complex Database-Centric Applications with PL/pgSQL 1st
Edition Baji Shaik
https://ebookmass.com/product/procedural-programming-with-postgresql-
pl-pgsql-design-complex-database-centric-applications-with-pl-
pgsql-1st-edition-baji-shaik/
ebookmass.com

Pro Oracle SQL Development: Best Practices for Writing


Advanced Queries 2nd Edition Jon Heller

https://ebookmass.com/product/pro-oracle-sql-development-best-
practices-for-writing-advanced-queries-2nd-edition-jon-heller/

ebookmass.com
Modern Oracle
Database
Programming
Level Up Your Skill Set to Oracle’s Latest
and Most Powerful Features in SQL,
PL/SQL, and JSON

Alex Nuijten
Patrick Barel
Foreword by Chris Saxon
Modern Oracle Database
Programming
Level Up Your Skill Set to Oracle’s
Latest and Most Powerful Features
in SQL, PL/SQL, and JSON

Alex Nuijten
Patrick Barel
Foreword by Chris Saxon
Modern Oracle Database Programming: Level Up Your Skill Set to Oracle’s Latest
and Most Powerful Features in SQL, PL/SQL, and JSON

Alex Nuijten Patrick Barel


Oosterhout, Noord-Brabant, The Netherlands Almere, Flevoland, The Netherlands

ISBN-13 (pbk): 978-1-4842-9165-8 ISBN-13 (electronic): 978-1-4842-9166-5


https://doi.org/10.1007/978-1-4842-9166-5

Copyright © 2023 by Alex Nuijten, Patrick Barel


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Jonathan Gennick
Development Editor: Laura Berendson
Editorial Assistant: Shaul Elson
Copyeditor: Kim Burton
Cover designed by eStudioCalamar
Cover image by Omar Flores on Unsplash
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
Suite 4600, New York, NY 10004-1562, USA. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole
member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc
is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at https://github.com/Apress/modern-oracle-
database-programming. For more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Table of Contents
About the Authors�������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv


Foreword���������������������������������������������������������������������������������������������������������������xvii

Acknowledgments��������������������������������������������������������������������������������������������������xix

Introduction������������������������������������������������������������������������������������������������������������xxi

Part I: Advanced Basics���������������������������������������������������������������������������������� 1


Chapter 1: Underutilized Functionality and Enhancements�������������������������������������� 3
Merge�������������������������������������������������������������������������������������������������������������������������������������������� 3
Collections������������������������������������������������������������������������������������������������������������������������������������ 4
Bulk Collect����������������������������������������������������������������������������������������������������������������������������� 6
forall�������������������������������������������������������������������������������������������������������������������������������������� 10
Bulk Exceptions��������������������������������������������������������������������������������������������������������������������� 19
Compound Triggers��������������������������������������������������������������������������������������������������������������������� 19
Journaling����������������������������������������������������������������������������������������������������������������������������� 21
Mutating Table����������������������������������������������������������������������������������������������������������������������� 25
DML Error Logging���������������������������������������������������������������������������������������������������������������������� 28
Log Errors������������������������������������������������������������������������������������������������������������������������������ 28
Save Exceptions�������������������������������������������������������������������������������������������������������������������� 32
Summary������������������������������������������������������������������������������������������������������������������������������������ 34

Chapter 2: Analytic Functions and (un)Pivoting����������������������������������������������������� 35


Analytic Functions����������������������������������������������������������������������������������������������������������������������� 35
Building Blocks���������������������������������������������������������������������������������������������������������������������� 36
Running Totals����������������������������������������������������������������������������������������������������������������������� 37
Accessing Values from Other Rows��������������������������������������������������������������������������������������� 42

iii
Table of Contents

The Fastest Lap and the Slowest Lap����������������������������������������������������������������������������������������� 45


Ranking: Top-N���������������������������������������������������������������������������������������������������������������������������� 47
Deduplication������������������������������������������������������������������������������������������������������������������������������ 48
Reusable Windowing Clause������������������������������������������������������������������������������������������������������� 51
Pivot and Unpivot������������������������������������������������������������������������������������������������������������������������ 53
Pivot��������������������������������������������������������������������������������������������������������������������������������������� 53
Unpivot���������������������������������������������������������������������������������������������������������������������������������� 57
Summary������������������������������������������������������������������������������������������������������������������������������������ 61

Chapter 3: Joins����������������������������������������������������������������������������������������������������� 63
Why Choose ANSI Joins?������������������������������������������������������������������������������������������������������������ 63
Natural Joins������������������������������������������������������������������������������������������������������������������������������� 64
Inner Joins���������������������������������������������������������������������������������������������������������������������������������� 66
Outer Joins���������������������������������������������������������������������������������������������������������������������������������� 68
Almost Outer Joins���������������������������������������������������������������������������������������������������������������� 69
Full Outer Joins��������������������������������������������������������������������������������������������������������������������������� 71
Cross Joins��������������������������������������������������������������������������������������������������������������������������������� 72
Partitioned Outer Joins��������������������������������������������������������������������������������������������������������������� 73
Lateral Joins������������������������������������������������������������������������������������������������������������������������������� 75
Summary������������������������������������������������������������������������������������������������������������������������������������ 80

Chapter 4: Finding Patterns������������������������������������������������������������������������������������ 81


Looking for Contracts������������������������������������������������������������������������������������������������������������������ 81
Classifying the Records��������������������������������������������������������������������������������������������������������� 83
Logical Groups����������������������������������������������������������������������������������������������������������������������� 88
Faster at the End������������������������������������������������������������������������������������������������������������������������� 90
Winning?������������������������������������������������������������������������������������������������������������������������������������� 94
Undefined Classification�������������������������������������������������������������������������������������������������������� 97
Longest Winning Streak��������������������������������������������������������������������������������������������������������� 99
Pit Stops and Hazards��������������������������������������������������������������������������������������������������������������� 101
Summary���������������������������������������������������������������������������������������������������������������������������������� 106

iv
Table of Contents

Chapter 5: Pagination and Set Operators������������������������������������������������������������� 107


Top-N and Pagination���������������������������������������������������������������������������������������������������������������� 107
Row-Limiting Clause����������������������������������������������������������������������������������������������������������� 110
Pagination���������������������������������������������������������������������������������������������������������������������������� 114
Under the Hood�������������������������������������������������������������������������������������������������������������������� 117
Set Operators���������������������������������������������������������������������������������������������������������������������������� 118
Union����������������������������������������������������������������������������������������������������������������������������������� 120
Minus and Except���������������������������������������������������������������������������������������������������������������� 122
Intersect������������������������������������������������������������������������������������������������������������������������������ 125
Summary���������������������������������������������������������������������������������������������������������������������������������� 127

Chapter 6: Conditional Compilation���������������������������������������������������������������������� 129


Directives���������������������������������������������������������������������������������������������������������������������������������� 129
Selection Directive�������������������������������������������������������������������������������������������������������������� 129
Inquiry Directive������������������������������������������������������������������������������������������������������������������ 130
Error Directive��������������������������������������������������������������������������������������������������������������������� 135
DEPRECATE Pragma Directive��������������������������������������������������������������������������������������������� 136
Using Directives������������������������������������������������������������������������������������������������������������������� 138
Use Cases��������������������������������������������������������������������������������������������������������������������������������� 139
Checking for the Presence of New Features����������������������������������������������������������������������� 139
Showing Output of Debug and Test Code���������������������������������������������������������������������������� 141
Checking for the Correct Database Environment���������������������������������������������������������������� 148
Showing What’s Compiled�������������������������������������������������������������������������������������������������������� 151
Summary���������������������������������������������������������������������������������������������������������������������������������� 152

Chapter 7: Iterations and Qualified Expressions�������������������������������������������������� 153


Iterations����������������������������������������������������������������������������������������������������������������������������������� 153
Iteration Controls����������������������������������������������������������������������������������������������������������������� 153
PL/SQL Qualified Expressions��������������������������������������������������������������������������������������������������� 178
Records������������������������������������������������������������������������������������������������������������������������������� 178
Collections��������������������������������������������������������������������������������������������������������������������������� 182
Summary���������������������������������������������������������������������������������������������������������������������������������� 186

v
Table of Contents

Part II: Multiple Techniques and Languages����������������������������������������������� 187


Chapter 8: Polymorphic Table Functions and SQL Macros����������������������������������� 189
Polymorphic Table Functions���������������������������������������������������������������������������������������������������� 190
Function������������������������������������������������������������������������������������������������������������������������������� 190
Package������������������������������������������������������������������������������������������������������������������������������� 191
Usage����������������������������������������������������������������������������������������������������������������������������������� 192
Use Cases��������������������������������������������������������������������������������������������������������������������������������� 193
Split������������������������������������������������������������������������������������������������������������������������������������� 193
Calling the Polymorphic Function���������������������������������������������������������������������������������������� 200
Sum Intervals���������������������������������������������������������������������������������������������������������������������� 201
Aggregating Intervals���������������������������������������������������������������������������������������������������������� 209
SQL Macros������������������������������������������������������������������������������������������������������������������������������� 210
Table-Type SQL Macros������������������������������������������������������������������������������������������������������� 211
Scalar-Type SQL Macro������������������������������������������������������������������������������������������������������� 212
Use Cases��������������������������������������������������������������������������������������������������������������������������������� 212
Parametrized View��������������������������������������������������������������������������������������������������������������� 212
Column Splitter (Table)�������������������������������������������������������������������������������������������������������� 214
Mimic Other Databases (Scalar)������������������������������������������������������������������������������������������ 220
expand_sql_text������������������������������������������������������������������������������������������������������������������ 225
Summary���������������������������������������������������������������������������������������������������������������������������������� 227

Chapter 9: Subquery Factoring, the WITH Clause, Explained�������������������������������� 229


Monaco Podium������������������������������������������������������������������������������������������������������������������������ 229
Functions in the WITH clause���������������������������������������������������������������������������������������������������� 234
Recursive Subquery Factoring�������������������������������������������������������������������������������������������������� 239
Simulate Built-in Recursive Functions�������������������������������������������������������������������������������� 244
Summary���������������������������������������������������������������������������������������������������������������������������������� 255

Chapter 10: Calling PL/SQL from SQL������������������������������������������������������������������� 257


UDF Pragma������������������������������������������������������������������������������������������������������������������������������ 257
Deterministic����������������������������������������������������������������������������������������������������������������������������� 258
Result Cache����������������������������������������������������������������������������������������������������������������������������� 261

vi
Table of Contents

Hierarchical Profiler������������������������������������������������������������������������������������������������������������������ 263


DBMS_HPROF���������������������������������������������������������������������������������������������������������������������� 266
create_tables����������������������������������������������������������������������������������������������������������������������� 266
start_profiling���������������������������������������������������������������������������������������������������������������������� 267
stop_profiling���������������������������������������������������������������������������������������������������������������������� 268
analyze�������������������������������������������������������������������������������������������������������������������������������� 269
Report���������������������������������������������������������������������������������������������������������������������������������� 274
Summary���������������������������������������������������������������������������������������������������������������������������������� 280

Chapter 11: Storing JSON in the Database����������������������������������������������������������� 283


Stage Data Before Processing�������������������������������������������������������������������������������������������������� 283
Which Data Type to Choose?����������������������������������������������������������������������������������������������������� 284
JSON Constraint������������������������������������������������������������������������������������������������������������������������ 285
Under the Hood������������������������������������������������������������������������������������������������������������������������� 290
Major Differences Between TREAT and JSON Constructor������������������������������������������������������� 294
Determining the Structure�������������������������������������������������������������������������������������������������������� 297
Indexing JSON Documents�������������������������������������������������������������������������������������������������� 302
Searching for a Specific Key����������������������������������������������������������������������������������������������� 303
Ad Hoc Searching with the JSON Search Index������������������������������������������������������������������� 306
Multivalue Indexes��������������������������������������������������������������������������������������������������������������� 308
Summary���������������������������������������������������������������������������������������������������������������������������������� 309

Chapter 12: Path Expressions in JSON����������������������������������������������������������������� 311


Sample Data������������������������������������������������������������������������������������������������������������������������������ 311
JSON Data Types����������������������������������������������������������������������������������������������������������������������� 313
Path Expressions and Filters����������������������������������������������������������������������������������������������������� 313
Using Filter Conditions�������������������������������������������������������������������������������������������������������� 316
Item Methods����������������������������������������������������������������������������������������������������������������������� 323
Handling Errors in JSON Path Expressions�������������������������������������������������������������������������� 327
Dot Notation������������������������������������������������������������������������������������������������������������������������������ 330
Summary���������������������������������������������������������������������������������������������������������������������������������� 334

vii
Table of Contents

Chapter 13: SQL/JSON and Conditions����������������������������������������������������������������� 335


SQL/JSON Functions����������������������������������������������������������������������������������������������������������������� 335
JSON_VALUE����������������������������������������������������������������������������������������������������������������������� 335
JSON_QUERY����������������������������������������������������������������������������������������������������������������������� 341
JSON_TABLE������������������������������������������������������������������������������������������������������������������������ 345
JSON_SERIALIZE����������������������������������������������������������������������������������������������������������������� 354
SQL Conditions�������������������������������������������������������������������������������������������������������������������������� 356
Summary���������������������������������������������������������������������������������������������������������������������������������� 361

Chapter 14: Generate, Compare, and Manipulate JSON���������������������������������������� 363


Generating JSON Documents���������������������������������������������������������������������������������������������������� 363
Comparing JSON Documents���������������������������������������������������������������������������������������������������� 371
Changing a JSON Document����������������������������������������������������������������������������������������������������� 373
JSON and PL/SQL���������������������������������������������������������������������������������������������������������������������� 378
Constructing and Manipulating JSON with PL/SQL������������������������������������������������������������� 387
Summary���������������������������������������������������������������������������������������������������������������������������������� 391

Part III: Oracle-Provided Functionality������������������������������������������������������� 393


Chapter 15: Useful APEX Packages���������������������������������������������������������������������� 395
APEX Availability����������������������������������������������������������������������������������������������������������������������� 395
Calling Web Services����������������������������������������������������������������������������������������������������������������� 396
Getting Data from JSON������������������������������������������������������������������������������������������������������������ 401
Basic Spatial Functionality�������������������������������������������������������������������������������������������������������� 404
Utilities for Text Manipulations�������������������������������������������������������������������������������������������������� 406
Formatting a Message��������������������������������������������������������������������������������������������������������� 408
Please Initial Here���������������������������������������������������������������������������������������������������������������� 409
Parsing Data������������������������������������������������������������������������������������������������������������������������������ 410
Business Case��������������������������������������������������������������������������������������������������������������������� 410
Let’s Parse!�������������������������������������������������������������������������������������������������������������������������� 411

viii
Table of Contents

Working with ZIP Files�������������������������������������������������������������������������������������������������������������� 415


Unzipping Files�������������������������������������������������������������������������������������������������������������������� 416
Zipping Files������������������������������������������������������������������������������������������������������������������������ 417
Summary���������������������������������������������������������������������������������������������������������������������������������� 418

Chapter 16: Processing Data in the Background�������������������������������������������������� 419


Resource Intensive�������������������������������������������������������������������������������������������������������������������� 419
Queuing������������������������������������������������������������������������������������������������������������������������������������� 419
The Use Case���������������������������������������������������������������������������������������������������������������������������� 420
Setup����������������������������������������������������������������������������������������������������������������������������������������� 421
Queue Table and Queue������������������������������������������������������������������������������������������������������������ 422
Enqueue and Dequeue�������������������������������������������������������������������������������������������������������������� 424
Wrapper Procedures����������������������������������������������������������������������������������������������������������������� 426
PL/SQL Callback Notification���������������������������������������������������������������������������������������������������� 428
Seeing It in Action��������������������������������������������������������������������������������������������������������������������� 433
Exception Queue����������������������������������������������������������������������������������������������������������������������� 435
Advanced Queuing and JSON��������������������������������������������������������������������������������������������������� 438
Summary���������������������������������������������������������������������������������������������������������������������������������� 440

Chapter 17: Introspecting PL/SQL������������������������������������������������������������������������ 441


DBMS_SESSION���������������������������������������������������������������������������������������������������������������������� 441
current_is_role_enabled��������������������������������������������������������������������������������������������������� 441
set_role����������������������������������������������������������������������������������������������������������������������������� 442
set_nls������������������������������������������������������������������������������������������������������������������������������� 442
set_context������������������������������������������������������������������������������������������������������������������������ 443
clear_context��������������������������������������������������������������������������������������������������������������������� 446
clear_all_context��������������������������������������������������������������������������������������������������������������� 447
set_identifier��������������������������������������������������������������������������������������������������������������������� 447
clear_identifier������������������������������������������������������������������������������������������������������������������ 448
sleep���������������������������������������������������������������������������������������������������������������������������������� 448

ix
Table of Contents

DBMS_APPLICATION_INFO������������������������������������������������������������������������������������������������������ 449
set_module������������������������������������������������������������������������������������������������������������������������ 449
set_action�������������������������������������������������������������������������������������������������������������������������� 449
read_module��������������������������������������������������������������������������������������������������������������������� 450
DBMS_UTILITY������������������������������������������������������������������������������������������������������������������������ 451
compile_schema��������������������������������������������������������������������������������������������������������������� 451
format_call_stack������������������������������������������������������������������������������������������������������������� 452
format_error_stack����������������������������������������������������������������������������������������������������������� 454
comma_to_table��������������������������������������������������������������������������������������������������������������� 455
expand_sql_text���������������������������������������������������������������������������������������������������������������� 459
UTL_CALL_STACK������������������������������������������������������������������������������������������������������������������� 463
subprogram����������������������������������������������������������������������������������������������������������������������� 466
concatenate_subprogram������������������������������������������������������������������������������������������������� 467
owner�������������������������������������������������������������������������������������������������������������������������������� 469
unit_line���������������������������������������������������������������������������������������������������������������������������� 469
Summary�������������������������������������������������������������������������������������������������������������������������������� 470

Chapter 18: See What You Need to See����������������������������������������������������������������� 471


Temporal Validity����������������������������������������������������������������������������������������������������������������������� 471
Setup����������������������������������������������������������������������������������������������������������������������������������� 471
as of Queries����������������������������������������������������������������������������������������������������������������������� 475
Versions Between Queries��������������������������������������������������������������������������������������������������� 477
DBMS_FLASHBACK_ARCHIVE���������������������������������������������������������������������������������������������� 479
Virtual Private Database������������������������������������������������������������������������������������������������������������ 481
The Policy Function������������������������������������������������������������������������������������������������������������� 482
Context�������������������������������������������������������������������������������������������������������������������������������� 483
Policy����������������������������������������������������������������������������������������������������������������������������������� 484
Complex Policies����������������������������������������������������������������������������������������������������������������� 493

x
Table of Contents

Redaction���������������������������������������������������������������������������������������������������������������������������������� 495
add_policy��������������������������������������������������������������������������������������������������������������������������� 496
alter_policy�������������������������������������������������������������������������������������������������������������������������� 501
drop_policy�������������������������������������������������������������������������������������������������������������������������� 504
Summary���������������������������������������������������������������������������������������������������������������������������������� 504

Chapter 19: Upgrade Your Application with Zero Downtime�������������������������������� 505


Downtime���������������������������������������������������������������������������������������������������������������������������������� 505
Definitions��������������������������������������������������������������������������������������������������������������������������������� 506
Concept������������������������������������������������������������������������������������������������������������������������������������� 507
The Challenges of Zero-Downtime Upgrades���������������������������������������������������������������������� 508
Solution������������������������������������������������������������������������������������������������������������������������������� 509
Dependencies���������������������������������������������������������������������������������������������������������������������� 510
Preparation������������������������������������������������������������������������������������������������������������������������������� 511
Privileges����������������������������������������������������������������������������������������������������������������������������� 512
Several Levels of Complexity���������������������������������������������������������������������������������������������������� 513
Only Changing PL/SQL Objects�������������������������������������������������������������������������������������������� 514
Table Changes: Don’t Sync Between Editions��������������������������������������������������������������������� 519
Table Changes with Data Sync�������������������������������������������������������������������������������������������� 523
Retiring Older Editions�������������������������������������������������������������������������������������������������������������� 529
Change Default Edition�������������������������������������������������������������������������������������������������������� 530
Summary���������������������������������������������������������������������������������������������������������������������������������� 530

Chapter 20: Choosing the Right Table Type���������������������������������������������������������� 531


Heap Table�������������������������������������������������������������������������������������������������������������������������������� 531
Index������������������������������������������������������������������������������������������������������������������������������������ 532
B-tree���������������������������������������������������������������������������������������������������������������������������������� 534
Bitmap Index����������������������������������������������������������������������������������������������������������������������� 534
Index-Organized Table (IOT)������������������������������������������������������������������������������������������������������ 534
Clusters������������������������������������������������������������������������������������������������������������������������������������� 536

xi
Table of Contents

Temporary Table������������������������������������������������������������������������������������������������������������������������ 541


Global Temporary Table������������������������������������������������������������������������������������������������������� 541
Private Temporary Table������������������������������������������������������������������������������������������������������ 547
Restrictions on Temporary Tables���������������������������������������������������������������������������������������� 552
External Table���������������������������������������������������������������������������������������������������������������������������� 553
Immutable Table������������������������������������������������������������������������������������������������������������������������ 559
Blockchain Table����������������������������������������������������������������������������������������������������������������������� 562
Summary���������������������������������������������������������������������������������������������������������������������������������� 563

Index��������������������������������������������������������������������������������������������������������������������� 567

xii
About the Authors
Alex Nuijten is an independent consultant specializing
in Oracle Database development with PL/SQL and Oracle
Application Express (APEX). Besides his consultancy work,
he conducts training classes in APEX, SQL, and PL/SQL.
He is a speaker at numerous international conferences,
including ODTUG, Oracle Open World, HrOUG, UKOUG,
IOUG, OUGF, BGOUG, NLOUG APEX World, OBUG, and
many more. He has received several Best Speaker awards
and writes regularly about APEX and Oracle Database
development on his Notes on Oracle blog. He is a co-author
of Oracle APEX Best Practices (Packt Publishing, 2012) and Real World SQL and PL/SQL
(McGraw Hill, 2016). Because of his contributions to the Oracle community, Alex was
awarded the Oracle ACE Director membership in August 2010.

Patrick Barel is a PL/SQL developer for Qualogy in The


Netherlands. Besides working with SQL and PL/SQL, he
has written different plug-ins for PL/SQL Developer. He
publishes articles on his own blog and the Qualogy blog. He
is a speaker at international conferences, such as ODTUG,
UKOUG, AUSOUG, NZOUG, IOUG, OUGN, NLOUG, DOUG,
HrOUG, and many more. In 2011, Patrick was awarded the
Oracle ACE membership. In 2015, he received the Oracle
Developer Choice Award in the PL/SQL Category. In 2019,
he was promoted to Oracle ACE Director.

xiii
About the Technical Reviewer
Kim Berg Hansen is a database developer from Middelfart,
Denmark.
As a youngster originally wanting to work with
electronics, he tried computer programming. He discovered
that the programs he wrote worked well—unlike the
electronics projects he soldered that often failed. This led to
a VIC-20 with 5 KB RAM and many hours of programming in
Commodore Basic.
Having discovered his talent, Kim financed computer
science studies at Odense University with a summer job as
sheriff of Legoredo while learning methodology and programming in Modula-2 and C.
From there, he moved into consulting as a developer making customizations to ERP
software. That gave him his first introduction to Oracle SQL and PL/SQL, with which he
has worked extensively since 2000.
His professional passion is to work with data inside the database utilizing the SQL
language to achieve the best application experience for users. With a background fitting
programs into 5 KB RAM, Kim hates unnecessarily wasting computing resources.
Kim shares his experience and knowledge by blogging at www.kibeha.dk, presenting
at various Oracle User Group conferences, and being the SQL quizmaster at the Oracle
Dev Gym. His motivation comes from peers who say, “now I understand,” after his
explanations, and end users who “can’t live without” his application coding. He is on the
conference committee of ODTUG Kscope, a certified Oracle OCE in SQL, and an Oracle
ACE Director.
Outside the coding world, Kim is married, loves to cook, and is a card-carrying
member of the Danish Beer Enthusiasts Association.

xv
Discovering Diverse Content Through
Random Scribd Documents
saw a multitude of Tomts come, each bearing a stalk of rye, among
them one not larger than a man’s thumb, bearing a straw upon his
shoulders.

“Why do you puff so hard?” said the farmer from his hiding-place,
“your burden is not so great.”

“His burden is according to his strength, for he is but one night old,”
answered one of the Tomts, “but hereafter you shall have less.”

From that day all luck disappeared from the farmer’s house, and
finally he was reduced to beggary.

In many districts it has been the custom to set out a bowl of mush for
the fairies on Christmas eve.

In the parish of Nyhil there are two estates lying near each other, and
both called Tobo. On one was a Tomt, who, on Christmas eve, was
usually entertained with wheaten mush and honey. One time the
mush was so warm when it was set out that the honey melted. When
the Tomt came to the place and failed to find his honey as
heretofore, he became so angry that he went to the stable and
choked one of the cows to death. After having done this he returned
and ate the mush, and, upon emptying the dish, found the honey in
the bottom. Repenting his deed of a few minutes before, he carried
the dead cow to a neighboring farm and led therefrom a similar cow
with which to replace the one he had killed. During his absence the
women had been to the barn and returned to the house, where the
loss was reported to the men, but when the latter arrived at the cow-
shed the missing [125]cow had apparently returned. The next day
they heard of the dead cow on the adjoining farm, and understood
that the Tomts had been at work.
In one place, in the municipality of Ydre, a housewife remarked that
however much she took of meal from the bins there seemed to be no
diminution of the store, but rather an augmentation. One day when
she went to the larder she espied, through the chinks of the door, a
little man sifting meal with all his might.

Noticing that his clothes were very much worn, she thought to
reward him for his labor and the good he had brought her, and made
him a new suit, which she hung upon the meal bin, hiding herself to
see what he would think of his new clothes. When the Tomt came
again he noticed the new garments, and at once exchanged his
tattered ones for the better, but when he began to sift and found that
the meal made his fine clothes dusty he threw the sieve into the
corner and said:

“Junker Grand is dusting himself. He shall sift no more.” [126]

1 The belief in Tomts has been handed down to us through many generations,
and is widespread in Sweden. In the opinion [123]of the writer they are nothing
more or less than an inheritance from the classical past and a remnant of the
domestic worship which the ancients bestowed upon their family gods. Legends
similar to this are related in Norway, where the spirit is called Topvette or
Tomlevette and Gardos; also in Faroe Islands, where they are called Niagriusar,
and in Germany, where they are called Kobolde, etc. ↑
[Contents]
The Cat of Norrhult. 1

On the estate of Norrhult, in the parish of Rumskulla, the people in


olden times were very much troubled by Trolls and ghosts. The
disturbances finally became so unbearable that they were compelled
to desert house and home, and seek an asylum with their neighbors.
One old man was left behind, and he, because he was so feeble that
he could not move with the rest.

Some time thereafter, there came one evening a man having with
him a bear, and asked for lodgings for himself and companion. The
old man consented, but expressed doubts about his guest being able
to endure the disturbances that were likely to occur during the night.

The stranger replied that he was not afraid of noises, and laid
himself down, with his bear, near the old man’s bed.

Only a few hours had passed, when a multitude of Trolls came into
the hut and began their usual clatter. Some of them built the fire in
the fireplace, others set the kettle upon the fire, and others again put
into the kettle a mess of filth, such as lizards, frogs, worms, etc.

When the mess was cooked, the table was laid and the Trolls sat
down to the repast. One of them threw a worm to the bear, and said:

“Will you have a fish, Kitty?” [127]

Another went to the bear keeper and asked him if he would not have
some of their food. At this the latter let loose the bear, which struck
about him so lustily that soon the whole swarm was flying through
the door.
Some time after, the door was again opened, and a Troll with mouth
so large that it filled the whole opening peeked in. “Sic him!” said the
bear keeper, and the bear soon hunted him away also.

In the morning the stranger gathered the people of the village around
him and directed them to raise a cross upon the estate, and to
engrave a prayer on Cross Mountain, where the Trolls dwelt, and
they would be freed from their troublesome visitors.

Seven years later a resident of Norrhult went to Norrköping. On his


way home he met a man who asked him where he came from, and,
upon being informed, claimed to be a neighbor, and invited the
peasant to ride with him on his black horse. Away they went at a
lively trot along the road, the peasant supposed, but in fact high up in
the air. When it became quite dark the horse stumbled so that the
peasant came near falling off.

“It is well you were able to hold on,” said the horseman. “That was
the point of the steeple of Linköping’s cathedral that the horse
stumbled against. Listen!” continued he. “Seven years ago I visited
Norrhult. You then had a vicious cat there; is it still alive?”

“Yes, truly, and many more,” said the peasant.

After a time the rider checked his horse and bade [128]the peasant
dismount. When the latter looked around him he found himself at
Cross Mountain, near his home.

Some time later another Troll came to the peasant’s cottage and
asked if that great savage cat still lived.

“Look out!” said the peasant, “she is lying there on the oven, and has
seven young ones, all worse than she.”
“Oh!” cried the Troll, and rushed for the door. From that time no
Trolls have ever visited Norrhult. [129]

1 Not longer than thirty years ago a cross, said to be the one raised on this
occasion, was still standing in Norrhult. ↑
[Contents]
Lady Barbro of Brokind. 1

On the estate of Brokind, in the parish of Vardsnäs, dwelt, in days


gone by, a rich and distinguished [130]lady named Barbro, who was so
hard-hearted and severe with her dependents that for the least
transgression they were bound, their hands behind their backs, and
cast into prison, where, to add to their misery, she caused a table,
upon which a bountiful supply of food and drink was placed, to be
spread before them, which, of course, bound as they were, they could
not reach. Upon complaint being made to her that the prisoners were
perishing from hunger and thirst, she would reply, laughingly: “They
have both food and drink; if they will not partake of it the fault is
theirs, not mine.”

Thus the prison at Brokind was known far and wide, and the spot
where it stood is to this day called Kisthagen, in memory of it.

When Lady Barbro finally died she was buried in the grave with her
forefathers, in the cathedral of Linköping, but this was followed by
such ghostly disturbances that it became necessary to take her body
up, when it was interred in the churchyard of Vardsnäs.

Neither was she at rest here, whereupon, at the suggestion of one of


the wiser men of the community, her body was again taken up, and,
drawn by a yoke of twin oxen, was conveyed to a swamp, where it
was deposited and a pole thrust through both coffin and corpse. Ever
after, at nightfall, an unearthly noise was heard in the swamp, and the
cry of “Barbro, pole! Barbro, pole!”

The spirit was, for the time being, quieted, but, as with ghosts in all
old places, it returned after a time, and often a light is seen in the
large, uninhabited building at Brokind. [131]
1 This story was found, after his death, among the papers of the lecturer, J.
Vallman. The estate of Brokind, before it came into the possession of the family
of Count Falkenberg, was owned, for about two centuries, by the family of Night
and Day. It is probable that the Lady Barbro wrought into this legend is Lady
Barbro, Erik’s daughter, wife of Senator Mons, Johnson Night and Day, though how
she was made to play a part in the narrative is not known, as her body was not
impaled in a swamp, but rests peacefully in an elegant grave in the cathedral of
Linköping. ↑
[Contents]
The Urko of North Wij. 1

From the point where the river Bulsjö empties into Lake Sommen,
extending in a northerly direction for about eight miles, bordering the
parishes of North Wij and Asby, nearly up to a point called Hornäs,
stretches the principal fjord, one of several branching off from the
large lake.

Near Vishult, in the first named of these parishes, descending to the


lake from the elevation that follows its west shores, is a wall-like
precipice, Urberg, which, from the lake, presents an especially
magnificent view, as well in its height and length, and in its wood-
crowned top, as in the wild confusion of rocks at its base, where,
among the jumble of piled-up slabs of stones, gape large openings,
into which only the imagination dares to intrude.

From this point the mountain range extends southward toward


Tulleram, and northward, along the shore of Lake Sjöhult, under the
name of Tjorgaberg, until it ends in an agglomeration of rocks called
Knut’s Den.

In this mountain dwells the Urko, a monster cow of traditionary


massiveness, which, in former times, when she was yet loose,
plowed the earth, making what is now Lake Sommen and its many
fjords. At last [132]she was captured and fettered by a Troll man from
Tulleram, who squeezed a horseshoe around the furious animal’s
neck and confined her in Urberg. For food she has before her a large
cow-hide from which she may eat a hair each Christmas eve, but
when all the hairs are consumed, she will be liberated and the
destruction of Ydre and all the world is to follow.
But even before this she will be liberated from her prison if Ydre is
crossed by a king whom she follows and kills if she can catch him
before he has crossed to the confines of the territory.

It happened one time that a king named Frode, or Fluga, passed


through Ydre, and, conscious of the danger, hurried to reach the
boundaries, but, believing he had already passed them, he halted on
the confines at Fruhammer, or, as the place was formerly called,
Flude, or Flugehammer, where he was overtaken and gored to death
by the monster. In confirmation of this incident, his grave, marked by
four stones, is to this day pointed out.

Another narrative, which, however, is known only in the southeastern


part of the territory, relates that another king, unconscious of the
danger accompanying travel in the neighborhood, passed unharmed
over the border, and had reached the estate of Kalleberg, when he
heard behind him the dreadful bellowing of the monster in full chase
after him. The king hastened away as speedily as possible. The cow
monster, unable to check its mad gallop at the border, rushed over
some distance to the place where the king first paused, where, in the
gravel-mixed field, she pawed up a round [133]hole of several
hundred feet in breadth, which became a bog, whose border,
especially upon the north side, is surrounded by a broad wall of the
upheaved earth.

Still, at times, especially preceding a storm, the Urko is heard rattling


its fetters in the mountain, and both upon the mountain and down
near the shore of the lake by times.

Extraordinary things are said to happen. One and another of the


residents thereabouts assert even that they have seen the Urko in
her magnificent rooms and halls, which the neighbors do not for a
moment doubt. [134]
1 This legend doubtless grew out of the story of the flood, in this form relating how
the mighty waters burst their bounds and were in time again imprisoned in their
beds. ↑
[Contents]
The Troll Shoes.

Near Kölefors, in the jurisdiction of Kinda, lived, a long time ago, an


old woman, who, as the saying goes, was accustomed, during Easter
week, to go to Blåkulla.

Late one Passion Wednesday evening, as was usual with witches,


she lashed her pack in readiness for the night, to follow her comrades
in their wanderings. In order that the start should be accompanied by
as few [135]hindrances as possible, she had greased her shoes and
stood them by the fireplace to dry.

In the dusk of the evening there came to her hut another old woman,
tired and wet through from the rain, and asked permission to remain
over night. To this the witch would not consent, but agreed to allow
the woman to remain until she had dried her soggy shoes before the
fire, while she, unwilling to be under the same roof with her guest,
remained outside.

After a time the fire died out, and it became so dark in the hut that
when the stranger undertook to find her shoes, in order to continue
her journey, she got and put on the witch’s shoes instead. Hardly had
she passed out through the door when the shoes jerked her legs up
into the air and stood her head downward, without, however, lifting
her into the air and carrying her away as would have been if the
witch’s broom had been in her hand.

In this condition the old woman and the shoes struggled through the
night. Now the shoes stood her on her head and dragged her along
the ground, now the woman succeeded in grasping a bush or root,
and was able to regain her feet again for a time.
In the end, near morning, a man walking past, noticed her and
hastened to her relief. Answering her earnest pleading the man poked
off one of the shoes with a stick, whereupon, instantly, shoe and stick
flew into the air and vanished in the twinkling of an eye. After the
adventures of the night the old Troll woman was so weakened that
she fell into a hole, which is pointed out to this day, and is called “The
Troll Woman’s Pit.” [136]
[Contents]
The Wood and the Sea Nymphs. 1

Both wood nymphs and sea nymphs belong to the giant family, and
thus are related.

They often hold communication with each other, although the wood
nymphs always hold themselves a little above their cousins, which
frequently occasions differences between them.

A peasant, lying in the woods on the shores of Lake Ömmeln, heard


early one morning voices at the lake side engaged in vehement
conversation. Conjecturing that it was the wood nymphs and sea
nymphs quarreling, he crept through the underbrush to a spot near
where they sat, and listened to the following dialogue:

Sea Nymph—“You shall not say that you are better than I, for I have
five golden halls and fifty silver cans in each hall.”

Wood Nymph—“I have a mountain which is three miles long and six
thousand feet high, and under that mountain is another, ten times
higher and formed entirely of bones of the people I have killed.”

When the peasant heard this he became so alarmed [137]that he ran


a league away, without stopping. Thus he did not learn which was
victorious, but it was the wood nymphs without doubt, as they have
always been a little superior to the others. [138]

1 The wood nymph dwells in large forests, and is described as a beautiful young
woman, when seen face to face; but if her back be turned to one it is hollow, like
a dough-trough, or resembles a block stub. Sometimes, instead of a hollow back,
she is adorned with a bushy fox tail. The sea nymph dwells, as indicated by the
name, at the bottom of seas and lakes, and is clad in a skirt so snow-white that it
sparkles in the sunlight. Over the skirt she wears a light blue jacket. Usually her
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookmass.com

You might also like