Skip to main content


Showing posts from 2019

Appreciation for Those Who Give of Themselves (#ThanksOGB)

My #ThanksOGB post:

I've been working - and personally benefiting from - Oracle Database technology since 1987. I joined Oracle as a pre-sales consultant, which meant back then I was a techie sidekick for one or more Oracle salespeople. I moved on to various other roles and in 1992 left to become a consultant. Two years later, wrote a book on PL/SQL and have been obsessed with that language ever since. In 1999, I released the first version of utPLSQL - unit test for PLSQL, my version of JUnit. Worked for Quest for many years (bringing Quest Code Tester for Oracle to the market, among other things), and in 2014 rejoined Oracle, where I now lead a team of developer advocates (Blaine Carter, Chris Saxon, Connor McDonald, Dan McGhan).

It's been a great life - and I expect it to keep on being such for a while to come. Part of the point of my little historical review, though, is that I was always paid to provide resources to the community (some of them free, like utPLSQL and my man…

Using Object Types in Relational Tables, Part 4

So far in my series on object-oriented development in Oracle Database, all manipulation of object type instances have taken place in PL/SQL.

But as you may have guessed from the fact that you "CREATE OR REPLACE" object types, those types are also available for us in SQL. You can create relational tables of object types, called object tables. You can also define columns of relational tables whose datatypes are object types.

In this post, I will explore both of these approaches. All the code you see below may be found in this LiveSQL script, so you can get to know these features by playing around with them yourself.
Object Tables It's easy to create object tables and work with the instances in those tables (both selecting and changing rows of data). Here's a simple example:
CREATE TYPE food_ot AS OBJECT ( name VARCHAR2 (100), food_group VARCHAR2 (50), grown_in VARCHAR2 (100) ) NOT FINAL / CREATE TABLE food_table OF food_ot (CONSTRAINT food_table_pk PRIMA…

Using Always Free Autonomous Database to help me heal our planet

So I signed up for my Always Free Autonomous Database (AFAD) and a boatload of other cloud services. OK, what shall I do with them? some of you may know, I've gotten very concerned about climate change and human-caused extinctions. I started a project with Vincent Morneau called fabe - for all a beautiful earth - to help all of us reduce consumption, rescue species and reconnect to nature. Check it out at Yes, it is an APEX application and it is already running on an Oracle Database cloud service, so....what else?

You know the saying "think globally, act locally"? Well, if fabe is global, then my work on invasive species is local, very local.

When I lived in Chicago, I went out to the nearest "wild" spaces I could find and cut back buckthorn trees that didn't belong in Chicago, out-competed native trees for sunlight, and killed off those native species. I rescued trees - and the literally millions of living creatures t…

Always Free Autonomous Oracle Database: Let's get going!

On September 16, Larry Ellison announced a new Always Free tier for Oracle Cloud, which (for me) most importantly includes an Always Free Autonomous Oracle Database.

For nothing but the "cost" of providing your credit card information (which is only used for identification purposes and is henceforth ignored until you decide to upgrade to a paid service), everyone in the world now can use the most powerful, most advanced database in the world FOR FREE.

Of course, there are limits. But oh my what generous limits they are!

Get lots more details here.

And it's not just the amazing Autonomous Database (in both transaction processing and data warehouse flavors).

You get Oracle Application Express (APEX) so you can build websites writing very little code, and taking full advantage of your SQL and PL/SQL skills.

You get SQL Developer to write what code you need and manage your database.

You get Oracle Rest Data Services to build REST endpoints against your database.

And if you …

Object Types and Object-Oriented Development with PL/SQL: the Series

Find below the list of my blog posts in a series on working with object types (a.k.a, classes) in Oracle Database and, specifically, PL/SQL.

This series is not intended to offer an in-depth training on object-oriented development; instead, it introduces basic O-O concepts and shows how they are implemented in Oracle Database with PL/SQL.

Introduction to Object Types, Part 1
Object Types and Inheritance, Part 2
Object Types Methods, Part 3
Using Object Types in Relational Tables, Part 4

Each post also contains a link to a LiveSQL script, so you can try out all the code yourself.

Still to come:

Comparison Methods, Part 5
Dynamic Polymorphism, Part 6

Object Type Methods, Part 3

Packages have subprograms (procedures and functions). Object types have methods.

Object type methods are, still, procedures and functions. But there are also different types and characteristics of methods that only make sense in an object type, which supports inheritance and dynamic polymorphism.

In this post, 3rd in my series on object types, I explore
Static methods Member methods Non-instantiable methods Invoking methods of super types All the code you see below can be run in Oracle LiveSQL through this script. Member Methods Member methods are methods applied to an instance of the type. Almost all the methods you ever write for an object type will be a member method. Assuming you are already familiar with writing PL/SQL functions and procedures, the most important thing to come up to speed on is the SELF value.

Member methods have a built-in (implicit) parameter named SELF that denotes the object instance currently invoking the method.

We'll explore member methods, including a…

Object Types and Inheritance, Part 2

In my first post on object-oriented programming in PL/SQL, I introduced the object type (our version of a class) and showed how you needed to instantiate an object type instance before you could work with it.

In this post, I explore how to create a hierarchy of types. Type or class hierarchies are a key concept in object-oriented programming, because of the way that subtypes inherit attributes and methods from their parent types. All the code you see below can be run in Oracle LiveSQL through this script.

Let's revisit the root type of my hierarchy: food.
CREATE TYPE food_ot AS OBJECT ( name VARCHAR2(100), food_group VARCHAR2 (50), grown_in VARCHAR2 (100) ) NOT FINAL ; A very simple type: it contains just three attributes and no methods (procedures or functions). It also contains the NOT FINAL clause. This means, rather obviously, that I am "not done." What that means in the context of object types is that I might want to create a subtype of …

The Ten Commandments of PL/SQL Development

A long, long time ago in a blog long ago lost to the shrouds and clouds of memory, I published a Ten Commandments of PL/SQL Development.

A Twitter follower recently asked me for them, and lo and behold actually found them lurking in a Word doc on my drive. So I have decided to share them with you, largely unchanged. In some places I have struck through entirely irrelevant or outdated text, and also offered updates for 2019.
1. Thou shalt encapsulate your SQL statements behind procedure and function calls. Sure, it's really, really easy to write SQL in your PL/SQL programs -- in fact, it's way too easy. SQL is the "Achilles' heel" of your application code. You code and you code and you code, and before you know it, you have dozens of variations of the same SQL statement making their negative performance impact known in your application. You can't analyze the impact of data structure changes and you find enhancements to be very expensive. Solution? Put all your…

A "SQL Guard" utility to help with SQL injection - available "AS IS"

I was asked the following question via a Twitter DM today:
I stumbled upon a mention of "SQL Guard" and I was wondering what has become of it. Google confused me. Has it been published under some other name, or is it part of a bigger product? Great question! I sort of vaguely remembered creating something like that. So I searched around in my folders and found....SQL Guard!

NOTE: SQL Guard is not a product I offer anywhere on the Internet. There are things out there called SQL Guard. I am not challenging their copyright or trademark or anything else.

What you find will find below is the document I wrote in 2007 explaining my ideas and code.

I am making it available AS IS through this site and a set of LiveSQL scripts, links below. I make no warranty about usability or usefulness or even basic validity of this code. If it helps you great. If it destroys your database I WARNED YOU.

LiveSQL: create tables
LiveSQL: create package specification
LiveSQL: create package body
LiveSQL: …