GlossaryTechnology

PL/SQL

Term 169 of 268 · Technology

In one sentence

PL/SQL is Oracle Database's procedural language. It extends SQL with variables, flow control and error handling, and lets you write stored procedures, functions, packages and triggers that run inside the database, where many companies with an Oracle ERP keep critical business logic.

Reviewed by Juan Manuel Garrido

Co-founder of VantegrateLinkedIn

PL/SQL definition

PL/SQL (Procedural Language/SQL) is the procedural programming language of Oracle Database. It extends standard SQL with variables, conditionals, loops, cursors and exception handling, and lets you write complete logic that runs inside the database engine as stored procedures, functions, packages and triggers.

Its defining trait is where it lives: PL/SQL code is compiled and executed on the database server, right next to the data. That is why, in companies that have been running for years on products like Oracle E-Business Suite or on custom systems built on Oracle, it is common for decades of business rules (pricing calculations, tax validations, accounting closes, interfaces between modules) to be implemented in PL/SQL rather than in the application layer.

That concentration of logic has a practical consequence: it cannot be seen from the outside. An integration or migration project that only surveys screens and services misses a central part of the system; understanding what the existing PL/SQL does is a mandatory part of the assessment before touching an Oracle environment with history.

What you build with PL/SQL

PL/SQL code does not live in an application's files: it is stored and compiled inside the database itself, as named objects that any authorized process can invoke. The main ones are:

  • Stored procedures: routines that encapsulate a complete operation, for example recording a payment, updating the customer's balance and posting the journal entry in a single transaction.
  • Functions: they return a value and can be called from SQL queries; they are typical for reusable calculations such as taxes, exchange rates or rounding rules.
  • Packages: they group related procedures and functions into a module with a public interface and a private body; they are the natural unit for organizing large business logic.
  • Triggers: they fire on their own on an INSERT, UPDATE or DELETE against a table; they are used for auditing, validations and synchronization between tables.

PL/SQL and SQL

They do not compete: they complement each other. SQL handles access to the data, and PL/SQL adds the ability to program complete processes around those queries.

AspectSQLPL/SQL
NatureDeclarative: describes what data is neededProcedural: describes how to process it
Unit of workIndividual statementsBlocks, procedures, packages
Flow controlNoneIF, LOOP, CASE, exception handling
PortabilityRelatively standard across enginesProprietary to Oracle

The last row is the one that matters in projects: a reasonably standard SQL query can be moved between engines with limited adjustments, while PL/SQL code has to be converted or rewritten if the company changes data platforms.

Why the logic lives in the database

For decades, running logic next to the data was the most efficient and secure way to build transactional systems: no network round trips, native commit and rollback, and a single place to audit what happened. Products like Oracle E-Business Suite carry that philosophy in their architecture, and internal teams extended it for years with their own customizations. The typical result in LatAm companies with an Oracle ERP is that the operational core, with its invoicing, inventory, settlements and accounting interfaces, is accumulated PL/SQL code that is rarely fully documented and that usually only a few people understand.

Impact on integrations and migrations

Logic in the database is invisible from the outside: an ETL process that writes to a table can fire triggers without knowing it, and an interface that bypasses the application can skip validations that only exist in a package. That is why, before designing an integration with an Oracle system, it pays to survey the PL/SQL involved and document what each object does. In a migration to a cloud ERP such as Oracle Fusion Cloud, the work is bigger: the existing logic is classified piece by piece to decide what the new product's standard covers, what gets rewritten as an extension or on an integration layer, and what gets retired because the process changed. Doing that survey at the start of the project, and not when the errors show up, makes the difference between a predictable migration and one full of surprises.

In practice

A price list that lives in PL/SQL packages

An Argentine wholesale distributor has run since the nineties on its own system built on Oracle Database: channel prices, volume discounts and tax calculations live in PL/SQL packages written by different teams over time. When it launches a B2B e-commerce site, the project starts by surveying that logic to expose it as services, instead of duplicating the pricing rules in the new application and risking differences between what the sales rep quotes and what the website shows.

An inventory of triggers before migrating the ERP

A Mexican pharmaceutical company plans to move from its on-premises Oracle ERP to a cloud ERP. The initial survey finds triggers and procedures that validate lots, expiration dates and product release, plus accounting interfaces written as PL/SQL jobs. Instead of migrating blindly, the team classifies each object: what the new ERP's standard covers is dropped, the regulatory validations are reimplemented as extensions, and the interfaces are rebuilt on a modern integration layer.

Share
Frequently asked questions

FAQs about PL/SQL

What is a stored procedure in PL/SQL?

It is a named routine written in PL/SQL that is stored and compiled inside Oracle Database. It encapsulates a complete operation, for example recording an invoice, updating inventory and leaving the audit trail in a single transaction, and it is invoked from applications, jobs or integrations. The advantage is that the logic runs next to the data with native transactions; the downside is that it stays out of view for anyone who only analyzes the application layer.

Does PL/SQL work outside Oracle Database?

No. PL/SQL is a proprietary Oracle language and runs inside its engines: Oracle Database on premises, the database on OCI and Oracle Autonomous Database. Other engines have procedural languages with similar concepts, such as T-SQL in SQL Server or PL/pgSQL in PostgreSQL, but the syntax is incompatible: changing engines means converting or rewriting the existing code, not copying it.

Should you write new business logic in PL/SQL?

It depends on the context. If the core system is an Oracle ERP and the logic is data-intensive, such as closes, bulk settlements or transactional validations, it is still an efficient and mature option. If your company is moving toward a cloud architecture, it is worth considering placing new logic in more visible, decoupled layers so you do not grow the debt that later makes migrations more expensive.

What happens to PL/SQL code when you migrate to a cloud ERP?

It is not migrated as is: in a SaaS ERP you do not install your own packages inside the vendor's database. The existing logic is surveyed and decided case by case: what the new product's standard covers, what gets rewritten as an extension or as a flow on a platform like Oracle Integration Cloud, and what gets retired because the business process changed with the migration.

What is the Salesforce equivalent of PL/SQL?

The equivalent role is played by Apex, the language used to program business logic inside the Salesforce platform. The main difference is architectural: PL/SQL runs inside the database with the server's resources, while Apex runs on a multi-tenant platform and is subject to governor limits that regulate shared consumption. In both cases the logic lives on the platform side and not in a separate application layer.

We bring this to your Oracle

Oracle implementation, integration and support for LatAm companies, connected to your CRM, WhatsApp and the rest of your stack. Tell us which modules you run today.

Keep exploring

Related terms

From the glossary

Related questions

We solve it with

Oracle

Oracle implementation, integration and support for LatAm companies, connected to the CRM and the rest of the stack.

How Oracle solves it
The full suite
Now that you know what it is, see how it gets solved

Five AI products that work on top of the CRM you already use. They don't replace your system: they add the layer you do by hand today.