Posts

Oracle AskTOM Office Hours: free, live Q&A sessions with Oracle experts!

Image
The Oracle AskTOM website is one of the go-to forums to get your questions answered on Oracle Database technology. For many years, it was managed singlehandedly by the legendary Tom Kyte. Since retirement in 2015, questions have answered by an expanded answer team of Chris Saxon, Connor McDonald and Maria Colgan. Chris and Connor are members of my Oracle Developer Advocates team, which also maintains and enhances the AskTOM site.

And we sure have been enhancing! In fact, we just released version 4 of the site, which adds a whole new, exciting program: Office Hours.



Office Hours offers scheduled, live Q&A sessions with a wide variety of Oracle Database experts, from product managers to evangelists and even developers. All ready, willing and able to help you get the best out of Oracle technology. 
And the best part: AskTOM Office Hours sessions are 100% free! AskTOM Office Hours continues the pioneering tradition of Ask TOM. Launched in 2000 by Tom Kyte, the site now has a dedicated tea…

Fifty top PL/SQL players heading to the Dev Gym Championship!

Image
2017 is no more. Which means that there are no more quizzes to be taken in 2017. Which means that we can now compute the rankings for the weekly PL/SQL tournament at the Dev Gym - and get ready for the 2017 championship event!

The top fifty-ranked players from 2017 will be invited to participate in the PL/SQL Challenge Championship for 2017, which will take place in March 2018 (date still to be finalized).

The number in parentheses after their names are the number of championships in which they have already participated. As you can see, many of these players are incredibly dedicated to their craft as Oracle Database Developers generally and to their standing on the Dev Gym in particular.

Congratulations to all listed below on their accomplishment and best of luck in the upcoming competition!

By the way, if you are not yet taking our weekly tournament quizzes at the Dev Gym, give it a try. You do not have to play competitively; you can opt-out of rankings.  Heck, you can even play inc…

Implicit vs Explicit Cursor: Which should you use?

Image
My post on Conditional Logic in PL/SQL generated some interesting discussion concerning whether to use an implicit cursor (SELECT-INTO) or an explicit cursor (OPEN-FETCH-CLOSE) when fetching a single row of data.

"Hmmm," you might be saying to yourself, "a conversation about SQL queries in a post on conditional logic? That's strange."

Ah, but maybe not so strange. Because as one person put it in the comments:


Yes, this is true. You can use exception handling as a kind of conditional branching logic. But should you? Generally, no. It's a good idea to keep application logic out of exception sections. Developers don't expect or look for business logic in those sections. They are, after all, for dealing with exceptions - errors. So if you put lots of code in EXCEPTION WHEN clauses, they can be easily overlooked, making your code harder to debug and enhance.

But that question - and the recommendation to avoid the exception section - then led to other comment…

PL/SQL 101: Nulls in PL/SQL

Image
The Oracle Database supports a concept of a null value, which means, essentially, that it has no value. The idea of having nulls in a relational database is controversial, but Oracle Database supports them and you need to know how they can impact your work in PL/SQL.

First, and most important, remember that:
Null is never equal to anything else, including null. And certainly 0.
Null is never not equal to anything else, including null.DECLARE var INTEGER; BEGIN IF var = NULL THEN ... IF NULL = NULL THEN ... IF var <> NULL THEN ... IF NULL != NULL THEN ... END;
you can rest assured that the code represented by "..." will never be executed.

Note: NULL in the above code is a literal value with a non-value of null.

The same holds true for where clause predicates in a SQL statement. The following queries will never return any rows, regardless of the contents of the employees table.

SELECT * FROM employees WHERE employee_id = NULL / SELECT * FROM employe…

JSON in Oracle Database: resources to get you started

Image
I am (finally) diving in to explore and then write about using JSON in Oracle Database 12c - with SQL (Releases 1 and 2) and - more to the point for me - with PL/SQL (based on enhancements in Release 2).

Expect to see posts on this blog, articles in Oracle Magazine, quizzes and workouts at the Oracle Dev Gym, and more, in 2018.

To that end, I have been collecting links to useful resources on this topic, and I realized that you might benefit from that list just as much as I will. So why not share it now? :-)

Before exploring Oracle-specific resources, visit json.org to learn more about JSON itself.

Oracle Documentation

Let's start with the official source of truth: our doc set.

First and foremost, we have the Database JSON Developer's Guide, which covers how to store, generate, view, manipulate, manage, search, and query JSON.

And here are some specific links you might find handy:

Basic SQL/JSON Path Expression Syntax

The basic syntax of a SQL/JSON path expression is presented. …

PL/SQL 101: Declaring variables and constants

PL/SQL is, in almost all ways, a straightforward and deceptively simple programming language. The "deception" lies in how simplicity can sometimes mask capability. It is easy to learn the basics of PL/SQL, and you can become productive very quickly.  And then you also quickly see how powerful and capable is PL/SQL.

So I offer another post on PL/SQL fundamentals, this one offering key points to remember when declaring constants and variables.

Some General Points

1. You can only have declarations in the declaration section, which is found between the IS | AS | DECLARE keyword and the BEGIN keyword (which kicks off the executable section) or END keyword if declaring elements at the package level.

/* Anonymous and nested blocks*/ DECLARE ...declarations... BEGIN /* Procedures and functions */ PROCEDURE my_proc (...) IS | AS ...declarations... BEGIN /* Package specification and body */ PACKAGE my_pkg IS | AS ...declarations... END;
So to be clear: there is an explicit &…

"Write once, run anywhere" - PL/SQL comes to yet another database!

Back in the late 80s, some big brains at Oracle realized that an operating system independent language was needed to build applications on top of Oracle Database (and our SQL implementation). Their rapidly growing customer base was writing applications in C (making calls to SQL via the OCI layer), and that was problematic. Code needed to be ported, re-tested, etc. for variations of the C compiler on different systems. And C wasn't very easy to write.

They dreamed of programs, running inside the database itself, which could be moved from operating system to operating system, and not require any changes.
"Write once, run  anywhere (there's an Oracle Database)." Thus was PL/SQL born, as a sort of step-child of Ada (the syntax of PL/SQL was taken almost directly from Ada specs, to avoid having to invent an entirely new language).

It's such a great language that:
It offers the best performance for executing SQL in Oracle Database.It provides a simple yet powerful way t…