Key takeaways
- Error handling is business logic: it decides what a job does when something goes wrong, not just whether it stops.
- Oracle and Databricks raise, name and report errors differently, so handlers written for Oracle can miss, or catch the wrong thing.
- The same converted code can fail on one Databricks runtime and return empty values on another.
- Most error paths never run in testing, so these differences surface in production, on the bad day.
- Proving that every migrated procedure fails the same way it did on Oracle is specialist work, and it is what sign-off should rest on.
Short answer: Oracle PL/SQL code is full of exception handlers: small blocks that decide what happens when a lookup finds nothing, a division hits zero or a value doesn't fit. Databricks handles errors too, but it raises them differently, names them differently and, depending on settings, sometimes doesn't raise them at all. Move the code without proving its error behaviour and a job that used to recover quietly can stop the whole run, or a job that used to stop can carry on with wrong data.
This is the fourth article in our series on Oracle to Databricks migration, after Oracle empty strings and NULL, Oracle NUMBER and Databricks DECIMAL and our piece on cursor loops. For the bigger picture, see our guide to migrating Oracle stored procedures to Databricks.
Two ways of handling errors
In Oracle PL/SQL, when an error is raised, the block stops and control passes to its exception-handling part. If that block has no handler for the error, it propagates to the enclosing block, and finally to the caller. Oracle gives common errors fixed names and numbers: its predefined exceptions include NO_DATA_FOUND (ORA-01403), TOO_MANY_ROWS (ORA-01422), VALUE_ERROR (ORA-06502) and ZERO_DIVIDE (ORA-01476). Decades of code check those names, those numbers and even the message text.
Databricks reports errors as named error conditions with a SQLSTATE, such as DIVIDE_BY_ZERO. Databricks SQL scripting supports condition handlers in Databricks SQL and Databricks Runtime 16.3 and above, with CONTINUE handlers from Runtime 18.1. And whether some operations raise an error at all depends on ANSI mode, which is on by default from Databricks Runtime 17.0: with it on, an invalid cast fails the query; with it off, the same cast returns NULL. None of this lines up one-to-one with Oracle.
Where it shows up
When Oracle error handling moves to Databricks, the differences typically surface as:
- Jobs that stop instead of recovering. A handler that used to set a default and carry on never runs, and a nightly batch fails outright.
- Jobs that carry on instead of stopping. A bad value that Oracle rejected becomes an empty value, and the run finishes with gaps nobody sees.
- Different results on different runtimes. The same converted code raises an error on one cluster and returns NULL on another.
- Alerts and logs that go quiet. Monitoring, retry rules and support runbooks keyed to Oracle error codes stop matching anything.
- Partial work left in a different state. What was saved before the failure is not what downstream teams expect.
The hard part is that error paths rarely run. Clean test data never divides by zero or finds two rows where it expects one. The difference waits for the first bad day in production.
A real example
One thing our validation runs caught was a block that guarded a division: on Oracle, a zero divisor raised ZERO_DIVIDE, the handler set a fallback value and the procedure carried on. In an early converted version, the same input made Databricks raise its own error, in a form the handler wasn't waiting for. The fallback never ran and the whole procedure failed. Every test row with a normal divisor matched perfectly. Only a side-by-side run with a zero in the data showed the difference.
Another run went the other way. A sample procedure had a handler for a specific numeric-overflow error, and reading the code you would expect it to fire. On real Oracle it never does: the overflow raises a different error, which falls through to a catch-all handler that rolls back the run. A faithful migration has to reproduce what Oracle actually does, not what the code appears to say.
Why it's hard to catch at scale
One handler is easy to reason about. A real Oracle estate has hundreds, many of them catch-alls written years ago:
- It spreads. An error swallowed in one procedure becomes a missing row or a wrong balance several steps later.
- It hides. Error paths need bad data to run, so normal testing almost never exercises them.
- It's not alone. Error behaviour interacts with empty-string handling, numeric precision, loops and commits, and each makes the others harder to see.
- It needs decisions. Whether a bad record should stop the batch, be skipped or be logged is a business call, and many of those calls were made long ago by people who have moved on.
That's why teams find that converting the happy path is the easy part. Proving the unhappy paths still behave the same is where migrations stall.
How ITACC handles it
ITACC is a Databricks Brickbuilder Bronze Partner, part of Databricks' partner program, and we work with companies across North America, in Canada and the US, moving Oracle workloads onto Databricks.
We've built our own migration tooling and method around one principle: every migrated object is proven against your legacy results, or flagged with the reason. That includes how it fails, not just how it succeeds.
We convert Oracle SQL and PL/SQL, error handling included, to Databricks while keeping the behaviour your business logic depends on, and we hand you the evidence: what matches, what differs, and why. Our migration tooling runs inside your own environment, so your data stays where you keep it, including in Canada. Your team spends its time on decisions, not on chasing failed jobs.
The next article in this series covers Oracle sequences and Databricks identity columns. Not sure where your own risk sits? Try our migration risk check.
ITACC is an AI and data engineering partner based in Oakville, Ontario, and a Databricks Brickbuilder Bronze Partner. Learn more about our data and workflow automation work.
Frequently asked questions
Does Databricks support exception handling like Oracle PL/SQL?
Databricks SQL scripting supports condition handlers in Databricks SQL and Databricks Runtime 16.3 and above, and Python code has its own error handling. But errors are named and raised differently from Oracle, so handlers written for Oracle errors don't carry over one-to-one.
Why would converted code fail on one cluster and not another?
Some operations, such as invalid casts, raise an error when ANSI mode is on and return NULL when it is off. ANSI mode is on by default from Databricks Runtime 17.0, so the runtime and its settings change what the same code does.
If our tests pass, is our error handling safe?
Not necessarily. Most tests use clean data, and error paths only run on bad data. A migration can pass every normal test and still behave differently the first time a lookup finds nothing or a value doesn't fit.
How do we know which of our procedures are affected?
Almost every PL/SQL estate relies on exception handlers, so the question is where the differences matter. The reliable answer comes from comparing migrated behaviour with legacy behaviour, failures included. We can show you on one of your own procedures.