SQL PL (Db2 12.1)

This assessment applies the coupling account — coupling as access to a shared resource, and the coupling floor [1], [2] — and the knowledge-embodiment theorem [3]; the language is assessed against its official reference [4].

Snapshot SQL PL (Db2 12.1) — released 14 November 2024 · lifecycle current (Db2 12.1 for Linux, UNIX, and Windows; the current release line, with modpack 12.1.5 shipped in June 2026 and monthly updates since September 2026.)

Family SQL PL — shelf: Data and Science

The language’s primary object is a dataset or a numeric array, not a program loop. A shelf groups; it does not classify — the tags below carry every use, paradigm, and platform of this snapshot.

Trajectory OS/400 V4R2 (Db2 for i) (February 1998 — the first Db2 family member ships the SQL procedural language, following the SQL/PSM model) · Db2 12.1 (14 November 2024 — assessed release; the current release line)

Tags

Use — Query

Paradigm — Imperative, Procedural, Declarative

Lifecycle — Current

Memory — Runtime-managed

Typing — Static, strong

Resources

The language’s official entry points, and the documents that name the release this page assesses. A link marked this release pins the document to SQL PL (Db2 12.1); an unmarked link is the current reference for the language.

Landing page

Specification and reference

1 Assessment

This page assesses SQL PL in five parts: core coupling — what the language’s own constructs force; ecosystem coupling — what the surrounding platform, tooling, and community cost; engineering readiness — whether the artifact can be reproduced, verified, observed, worked in quickly, connected to other languages, and governed openly; the profile — the unscored facts a score cannot express; and the scoring detail — the mechanism marks and the arithmetic behind every score. A ✅ bullet marks a construct that helps. A ⚠️ or ❌ bullet marks a cost; the scoring model does not price every cost named here.

Core coupling 83.1/100 · Ecosystem coupling 80.1/100 · Engineering readiness 48.0/100

1.1 Core coupling

1.1.1 Type

  • ✅ Static typing over SQL data types: Every variable, parameter, and return value declares a type, and a body that violates its declarations fails when the routine is created
  • ✅ LIKE anchors a declaration to the schema: DECLARE v LIKE emp.salary follows the column’s type, so a column change does not require editing the declaration
  • ✅ Array types carry their element type: A VARCHAR(20) ARRAY or an associative array keeps a typed collection in one declared variable
  • ⚠️ Overloading resolves a call by argument type: Two routines may share a name and differ by their signature, so the argument list decides the target
  • ❌ NULL is the default value and it propagates (T10): A declared variable starts as NULL, three-valued logic applies, so IF x = 5 is not true when x is NULL
  • ❌ A signature says what a routine returns, not what it does (T12): A procedure that mutates tables, commits a transaction, or reads a nickname looks like any other procedure

1.1.2 Construction

  • ✅ A routine is a closed unit: Local variables, cursors, and conditions are private to the call, and the signature is the whole interface
  • ✅ Modules give a namespace and a boundary: CREATE MODULE groups routines, types, and variables, and an unpublished member is invisible to callers outside the module
  • ✅ Compound statements scope declarations: An inner BEGIN ... END holds its own variables, conditions, handlers, and cursors
  • ⚠️ Triggers fire implicitly: A trigger body runs in response to a data change, so the writer of a statement cannot see from the statement which code will run
  • ⚠️ A module’s variables live for the session: A variable declared in a module keeps its value across calls, so one call can read state another call wrote

1.1.3 Memory

  • ✅ No manual memory management: The Db2 engine owns the memory of its agents, and a routine never names an address or frees a byte
  • ✅ The server sizes the work areas: Sorts and hashes inside a routine’s statements take their memory from the engine’s heap configuration
  • ⚠️ A built collection holds its memory for the call: An ARRAY assembled with ARRAY_AGG or element by element materialises in the routine’s memory, so the call’s footprint follows the collection’s size
  • ⚠️ A declared global temporary table outlives the routine: A DECLARE GLOBAL TEMPORARY TABLE persists for the session, so a local act leaves a session-scoped resource behind

1.1.4 Error

  • ✅ Conditions and handlers separate the failure path: DECLARE ... CONDITION names a failure, and EXIT, CONTINUE, and UNDO HANDLER declare what happens when it is raised
  • ✅ Handlers match by class or by name: sqlexception, sqlwarning, and not found catch classes, and a declared condition catches its own
  • ✅ GET DIAGNOSTICS reads the failure’s detail: The handler can read the SQLSTATE, the message text, and the routine’s own diagnostics
  • ⚠️ A handler can swallow (Er3): A CONTINUE HANDLER that records nothing lets the routine proceed past the failure, and silence is indistinguishable from approval
  • ❌ A failure cannot travel as a value (Er4): The failure path is the handler path, so a fallible operation cannot be folded into an expression or returned as a result the caller inspects

1.1.5 Concurrency

  • ✅ A procedure can manage its own transaction: COMMIT, ROLLBACK, and SAVEPOINT are statements of the language, so a unit of work commits or aborts as one
  • ✅ Isolation and lock intent are declared in the query text: An isolation clause with USE AND KEEP UPDATE LOCKS on a SELECT ... FOR UPDATE names the locking the statement needs
  • ❌ Special registers are session state (K2): CURRENT SCHEMA, CURRENT PATH, and the other special registers are set per session and visible to every routine that runs there
  • ⚠️ Transaction isolation and declared locks do not order independent work: Two sessions’ multi-step work is ordered only by the locks its statements name, so any ordering the source relies on is an agreement no declaration carries

1.1.6 Platform

  • ❌ Cannot function outside one engine (P1): SQL PL runs on IBM Db2, so the unit of deployment is a Db2 database
  • ⚠️ The Db2 family carries dialect differences: A procedure written for Db2 on Linux, UNIX, and Windows is not guaranteed to compile unchanged on Db2 for i or Db2 for z/OS
  • ⚠️ The engine also accepts PL/SQL through a compatibility mode: A registry setting enables Oracle-syntax blocks, packages, and types, so one database can run two procedural dialects side by side
  • ⚠️ External routines run outside the SQL type system (T14): A LANGUAGE C, LANGUAGE JAVA, or CLR routine crosses a boundary no signature check reaches
  • ✅ Client interfaces are standard: ODBC, JDBC, and the CLP reach the engine, so a client is not bound to one binary protocol

1.1.7 Trade-offs (not coupling)

  • Logic beside the data is deliberate: A rule that runs beside its tables is enforced for every writer; the cost is that the rule sits outside the application’s test suite and profilers
  • An unpublished module member is deliberate encapsulation: Hiding internals from callers trades discoverability for a boundary the catalog enforces; the cost is that every consumer must learn which members are public
  • Dynamic SQL is deliberate for DDL and for a flexible filter: EXECUTE IMMEDIATE reaches names a static statement cannot; the cost is that the statement’s access path is chosen when it runs
  • A session-scoped module variable is a deliberate cache: Keeping a value across calls avoids a repeated read; the cost is staleness, since nothing invalidates the value when the underlying data changes

1.2 Ecosystem coupling

1.2.1 Performance

  • ✅ Routines compile into the catalog: A procedure’s body is compiled once at creation and the section is reused, so a call does not re-parse
  • ✅ Set-based statements in the body do the heavy lifting: One INSERT ... SELECT inside the procedure carries the optimiser’s plan, so the procedural wrapper is not the hot path
  • ⚠️ A plan regression arrives hidden inside the routine: A caller cannot see the queries inside a procedure, so a changed plan surfaces as the routine being slow

1.2.2 Ecosystem

  • ❌ The ecosystem is proprietary (Ec4): The engine, the tooling, and the support come from IBM under licence
  • ⚠️ A free community edition exists: Development can run without a licence, while the supported tooling and the enterprise features remain licensed
  • ✅ Decades of published practice: The Db2 documentation set and the wider IBM knowledge base cover the language with syntax and examples
  • ⚠️ Tooling centres on the engine’s own tools: The CLP and the IBM documentation carry the workflow, and the procedural language has no dedicated environment of its own

1.2.3 Evolution

  • ✅ Upgrades keep routines: A procedure written for an earlier Db2 release compiles in the current one
  • ✅ Deprecation is announced in the documentation: The knowledge centre marks deprecated and discontinued features before they go
  • ⚠️ A feature arrives with a release or a modpack: Adoption follows the server a deployment can upgrade to
  • ⚠️ IBM’s own decisions govern the change: The knowledge centre is the definition’s change log, and the block model follows the SQL/PSM concept without conforming to a published specification of the dialect

1.2.4 Domain

  • ✅ Excellent fit for data-centric logic: A routine runs beside its tables with SQL directly in the body, so a rule executes where the data is
  • ✅ A full procedural language inside SQL: Compound statements, array types, cursors, and condition handlers live in the same unit as the queries
  • ❌ Domain lock-in (D1): The language exists to run inside Db2, so the Db2 data tier is the only domain
  • ⚠️ It is not a runtime for arbitrary programs: A user interface, a heavy text workload, or a long-running service belongs in another language beside SQL PL

1.2.5 Learning

  • ✅ Gentle for a SQL developer: A compound statement reads like SQL with control flow added
  • ✅ The knowledge centre documents every construct: The Db2 documentation covers the syntax with runnable examples
  • ⚠️ The handler model takes practice: EXIT, CONTINUE, and UNDO handlers, condition matching, and handler scope are semantics the syntax does not show
  • ⚠️ Engine behaviour is a separate body of knowledge: Isolation levels, locking, and routine registration matter more than syntax for correct code

1.2.6 Syntax

  • ❌ Verbose (S1): Every routine needs a CREATE statement and a compound-statement body with its DECLARE section before it does anything
  • ✅ Keyword-led and readable: Statements read as verbs, and the block boundaries are visible in the source
  • ⚠️ END closes several constructs: END IF;, END LOOP;, and a routine’s labelled END must each be matched, so a long body is read against its terminators
  • ⚠️ The deployment script carries a statement terminator: A script must tell the CLP which character ends a routine body, usually @, so the source carries a convention of its own

1.2.7 Testing

  • ⚠️ No test framework ships with the toolchain (G1): The CLP and the Db2 tools provide no assertion or runner, so a suite is assembled from third-party harnesses or hand-rolled procedures
  • ✅ Third-party harnesses exist: db2unit and similar frameworks run Db2 unit tests with assertions and reporting
  • ✅ Transaction control isolates a test: A test can run inside a transaction that rolls back, leaving the database unchanged
  • ⚠️ A suite needs a server: Tests run inside the database they exercise, so the harness depends on a Db2 instance and on deployment rights
  • ❌ No monotonic reading published: the client’s time functions read the wall, and no elapsed reading ships (G4)

1.2.8 Security

  • ✅ Static SQL in a routine is parameterised: The routine’s variables bind as host variables of the compiled section, so values cannot change the parse
  • ✅ GRANT EXECUTE and roles express least privilege: Access is declared per routine, per module, and per schema
  • ✅ Row and column access control declares visibility in the schema: A row permission or a column mask filters what a statement can see regardless of which routine issues it
  • ⚠️ Static and dynamic privileges differ inside a routine: A routine’s static statements run with the definer’s rights while its dynamic statements check the invoker’s, so the two paths carry different grants
  • ❌ Known vulnerability/injection (Q3): EXECUTE IMMEDIATE with a built string turns concatenated input into code

1.2.9 Delivery targets

What ships from a producer to a consumer, and whether the interface across a release boundary is promised. Ec8 is present when one compiled target crosses with no promise.

Target Ships as Crosses a producer boundary Cross-release promise
stored program script no The database stores the source text and parses it; no compiled unit crosses a boundary

1.3 Engineering readiness

1.3.1 Reproducibility

  • ❌ The distribution records no toolchain version per project; the server version is a fact of the installation. (Y14)

1.3.2 Supply chain

  • ❌ Routine sources carry no signed provenance. (Y3)
  • ❌ No advisory feed joins CVEs to SQL PL libraries. (Y16)

1.3.3 Observability

  • ❌ No tracing standard exists in the language. (Y5)
  • ❌ The SIGNAL and message surfaces carry no structure. (Y6)

1.3.4 Feedback

  • ❌ No analyzer ships with the server; editor analysis rides third-party tools. (Y8)
  • ❌ No SQL PL debugger ships with the server. (Y13)

1.3.5 Interop

  • ❌ The routine runs only in Db2-family servers. (Y10)

1.3.6 Governance

  • ❌ IBM decides the language’s direction and release cadence. (Y11)
  • ❌ No public specification exists; the manuals document one implementation. (Y12)

1.4 Profile

Unscored, and kept separate from every score on purpose. The profile records what a mechanism price cannot express: what a running program costs, how well a coding model and an agent work in the language, and whether a safety-critical path exists.

1.4.1 Energy and cost

What this axis asks: what does a running program cost in energy and time?

  • ⚠️ Runs inside a database engine: energy and time are the engine’s, not the program’s.

1.4.2 AI and agent readiness

What this axis asks: how well does a coding model and an agent work in this language?

  • ❌ Procedural SQL is thin in model training data relative to mainstream languages, so generated SQL PL mixes in other dialects’ syntax [5].

1.4.3 Safety certification

What this axis asks: is there a certified or standards-qualified path to a safety-critical system?

  • ❌ No certified or standards-qualified path for safety-critical systems.

1.5 Scoring detail

1.5.1 Core coupling Dimensions

Dimension Mechanism Description Imposed by Present Weight
Type T1 dynamic no static check language — 0
T2 weak static language — 0
T3 dynamic/duck dispatch language — 0
T4 no sum types language — 0
T5 no generics language — 0
T6 no namespaces language — 0
T7 type erasure/reflection language — 0
T8 operator overloading language — 0
T9 inheritance required for polymorphism language — 0
T10 no null-safety language ✅ −8
T11 no module boundary language — 0
T12 no effect tracking language ✅ −8
T13 async/sync colouring language — 0
T14 unchecked foreign boundary language ✅ −4
T15 chars are encoding units language — 0
Type cost −5.7 (−20)
Construction C1 global mutable state by default language — 0
C2 no immutability by default language — 0
C3 constructors coupled to allocation language — 0
C4 no constructor/validation language — 0
C5 unpinned collection order language — 0
C6 aliasing by default language — 0
C7 undeclared control transfer language — 0
C8 no source-visible init order language — 0
Construction cost 0
Memory M1 manual deallocation runtime — 0
M2 GC non-deterministic pauses runtime — 0
M3 no RAII language — 0
M4 no ownership model language — 0
M5 uninitialized reads language — 0
M6 unchecked reinterpretation language — 0
Er6 uncatchable runtime fault language — 0
M7 reference cycles leak runtime — 0
Memory cost 0
Error Er1 no structured path language — 0
Er2 unchecked exceptions only language — 0
Er3 errors ignored/non-exhaustive language ✅ −4
Er4 no composable result type language ✅ −4
Er5 no isolation unit for a fault runtime — 0
Error cost −2.3 (−8)
Concurrency K1 GIL/no parallel runtime — 0
K2 shared mutable state default language ✅ −8
K3 manual sync no race detection runtime — 0
K4 no structured concurrency language — 0
K5 no primitives language — 0
K6 thread-per-task cost runtime — 0
Concurrency cost −2.3 (−8)
Platform P1 cannot function outside one vendor/domain context ✅ −15
P2 single-vendor but other uses context — 0
P3 legacy/discontinued platform context — 0
P4 poor domain fit context ✅ −8
Platform cost −6.6 (−23)

Core coupling score: 83.1/100 — 59 of the 350 inventory points are present, so the axis cost is 100 × 59 ÷ 350 = 16.9 and the score is 100 − 16.9. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

1.5.2 Ecosystem coupling Dimensions

Dimension Mechanism Description Imposed by Present Weight
Performance R1 interpreted no AOT/JIT runtime — 0
R2 GC pauses runtime — 0
R3 JIT warmup runtime — 0
Performance cost 0
Ecosystem Ec1 no package manager context — 0
Ec2 fragmented tooling context — 0
Ec3 small/niche/discontinued context — 0
Ec4 proprietary context ✅ −8
Ec5 platform-locked tooling context — 0
Ec6 monoculture context — 0
Ec7 legacy burden context — 0
Ec8 unpromised binary boundary context — 0
Ec9 unpromised data boundary context — 0
Ecosystem cost −3.1 (−8)
Evolution V1 breaking changes language — 0
V2 frozen context — 0
V3 discontinued context — 0
V4 glacial standards context — 0
V5 silent default drift runtime — 0
V7 build-variant state space context — 0
Evolution cost 0
Domain D1 domain/vendor lock-in context ✅ −15
D3 framework forces architecture context — 0
Domain cost −5.9 (−15)
Learning L1 steep context — 0
L2 large surface/multi-paradigm context — 0
L3 sparse docs context — 0
Learning cost 0
Syntax S1 verbose language ✅ −8
S2 inconsistent language — 0
S3 punctuation-heavy language — 0
Syntax cost −3.1 (−8)
Testing G1 weak tooling context ✅ −8
G2 poor debugging context — 0
G3 runtime-only errors context — 0
G4 no published monotonic clock runtime ✅ −4
Testing cost −4.7 (−12)
Security Q1 memory-unsafe language — 0
Q2 dynamic/weak typing risk language — 0
Q3 known vulnerability/injection context ✅ −8
Q4 silent integer overflow language — 0
Security cost −3.1 (−8)

Ecosystem coupling score: 80.1/100 — 51 of the 256 inventory points are present, so the axis cost is 100 × 51 ÷ 256 = 19.9 and the score is 100 − 19.9. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

1.5.3 Engineering readiness Dimensions

Dimension Mechanism Description Imposed by Present Weight
Reproducibility Y1 build not reproducible context — 0
Y2 dependencies not pinned context — 0
Y14 no toolchain version pin context ✅ −8
Y18 no machine-read project contract context — 0
Reproducibility cost −4.7 (−8)
Supply chain Y3 no signed provenance context ✅ −15
Y4 registry without namespacing context — 0
Y16 no advisory feed context ✅ −8
Supply chain cost −13.5 (−23)
Observability Y5 no stable tracing standard context ✅ −8
Y6 no structured logging context ✅ −4
Y15 no post-mortem diagnostics runtime — 0
Observability cost −7.0 (−12)
Feedback Y7 slow build context — 0
Y8 no fast in-editor analysis context ✅ −4
Y13 no bundled debugger context ✅ −8
Feedback cost −7.0 (−12)
Interop Y9 no foreign-function interface language — 0
Y10 no portable target context ✅ −4
Interop cost −2.3 (−4)
Governance Y11 single-vendor governance context ✅ −15
Y12 closed specification context ✅ −15
Y17 no conformance mechanism context — 0
Y19 no published parser context — 0
Governance cost −17.5 (−30)

Engineering readiness score: 48.0/100 — 89 of the 171 inventory points are present, so the axis cost is 100 × 89 ÷ 171 = 52.0 and the score is 100 − 52.0. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

Verdict: SQL PL’s coupling is set by its host engine and by IBM’s licence. Modules give a namespace with published and unpublished members, compound statements carry named conditions and handlers, static SQL in a routine is parameterised, and the knowledge centre documents the language in full. Main strengths: an explicit module boundary, a structured condition-and-handler error model, typed collections, and complete documentation. Main weaknesses: everything runs inside Db2, the proprietary licence owns the stack and the tooling, signatures carry no effects, a CONTINUE HANDLER can swallow a failure and let the routine proceed, dynamic SQL turns built strings into code, every variable starts as NULL and propagates, no test framework ships with the toolchain, and the block structure adds boilerplate to every routine.


The formal development. The definitions, theorems, and proofs behind this page are published in:

All published papers

References

[1]
Y. Loth, “On the nature of coupling: All coupling as shared resource access.” Zenodo, Aug. 2026. doi: 10.5281/zenodo.21925121.
[2]
Y. Loth, “Coupling as a consequence of cohesion: Decomposition, the coupling floor, and domain-imposed coupling.” Zenodo, Aug. 2026. doi: 10.5281/zenodo.21925201.
[3]
Y. Loth, “On the nature of cohesion: Cohesion as correctness relative to a partitioning rule.” Zenodo, Jul. 2026. doi: 10.5281/zenodo.20492912.
[4]
IBM Corporation, “IBM Db2 12.1 documentation: SQL procedural language (SQL PL).” IBM, 2024. Available: https://www.ibm.com/docs/en/db2/12.1.x?topic=data-sql-pl-support
[5]
S. Joel, J. J. Wu, and F. H. Fard, “A survey on LLM-based code generation for low-resource and domain-specific programming languages,” ACM Transactions on Software Engineering and Methodology, 2025, doi: 10.1145/3770084.