Posts

Showing posts from May, 2018

The SmartDB Resource Center

Image
I put together this blog post for those interested in learning more about the SmartDB (also or formerly known as "ThickDB") architecture and how to apply it in your applications. I will update it as more resources become available.

What is SmartDB?

Bryn Llewellyn, PL/SQL Product Manager, offers this description:

Large software systems must be built from modules. A module hides its implementation behind an interface that exposes its functionality. This is computer science’s most famous principle. For applications that use an Oracle Database, the database is, of course, one of the modules. The implementation details are the tables and the SQL statements that manipulate them. These are hidden behind a PL/SQL interface.

This is the Smart Database paradigm: select, insert, update, delete, merge, commit, and rollback are issued only from database PL/SQL. Developers and end-users of applications built this way are happy with their correctness, maintainability, security, and performa…

Mutating table errors and multi-row inserts

The Oracle Dev GymPL/SQL Challenge quiz played 28 Apr - 4 May explored the interactions between row-level triggers and multi-row inserts, particularly when it comes to mutating table errors. If you didn't happen to take the quiz and already learn its lesson, here goes.

[Note: you can also click on the link above and play the quiz right now, before you read this post!]

Here's the main rule to keep in mind:
A BEFORE INSERT trigger will not cause a mutating table error as long as the triggering INSERT statement is a single row insert (INSERT-VALUES). Let's take a closer look.

I create a table and a trigger on that table:

CREATE TABLE qz_flowers ( fl_num NUMBER, fl_name VARCHAR2 (30) ) / CREATE OR REPLACE TRIGGER qz_flowers_bir BEFORE INSERT ON qz_flowers FOR EACH ROW DECLARE l_count INTEGER; BEGIN SELECT COUNT (*) INTO l_count FROM qz_flowers; DBMS_OUTPUT.PUT_LINE ('Count = ' || l_count); END; /
The trigger queries from the qz_flowers table, …