SQL Editor & Stored Procedures
As of 2026-11-08T21:00:00.000Z
A SQL view or a stored procedure is the tool an architect reaches for the moment a graphical view builder cannot express the logic — window functions, recursive hierarchies, transactional ETL with rollback. The decision that separates senior from junior is not whether to write SQL, but which HANA object family to write it in: a badly-chosen cursor loop turns a 100,000-account load into 100,000 round-trips, and a stored procedure without checkpoint logic turns a 15-minute failure into a full reprocessing incident visible to the client's finance team. Get the SQL-view-vs-procedure-vs-table-function call right and a transformation scales to very large fact tables; get it wrong and it saturates a shared production HANA Cloud tenant during a go-live week. This module is the operating discipline for that call — not a syntax tour.
What you will learn
- Work through a realistic scenario: A European industrial-equipment manufacturer's finance team needs multi-currency, multi-ledger P&L reporting in Datasphere, and the existing graphical views can no longer keep the year-over-year window calculations and the ledger-union logic the controllers require readable.
- Recognize and avoid the anti-pattern: Cursor-per-key loop instead of a set-based JOIN — 100,000 accounts become 100,000 round-trips; a load that should take minutes runs for hours and can saturate the shared HANA Cloud tenant.
- Apply the module's core decision: SQL view vs graphical view vs stored procedure — choose: SQL view for window functions and set operations that stay read-only (SQLScript table function when the read logic needs branches or loops); stored procedure only when the logic must write to a target table with branching or transaction control; avoid: Defaulting to a stored procedure for read-only transformation logic — it cannot carry the Fact semantic usage, so it cannot be the source of an Analytic Model, which a SQL view can be.
- Track mastery with the KPI: Query plan quality (target: 0 full COLUMN TABLE SCAN on tables >10M rows without a filtering predicate; red flag: Any HASH JOIN or table scan on stale statistics reaching production untested).
SQL Editor & Stored Procedures in Datasphere and HANA Cloud
Datasphere's SQL editor and the SQLScript procedures of a space's Open SQL schema are the tools for logic the graphical view builder cannot express or should not carry. Three object families matter and they are not the same thing: SQL views with the language SQL (Standard Query) — a declarative SELECT that takes part in the semantic model like a graphical view; SQL views with the language SQLScript (Table Function) — Datasphere creates an SAP HANA Cloud table user-defined function, so IF statements and loops are allowed but the object is still read-only; and procedures created by a database user in the space's Open SQL schema, the only one of the three that writes tables, run as a step of a task chain. Knowing which family a requirement belongs to — and how the HANA Cloud engine executes it — decides whether a transformation scales or saturates the space's statement limits.
Source: SAP Datasphere — Run Open SQL Procedures in a Task Chain (SAP-docs mirror)
Prerequisites
- Intermediate hands-on experience on SAP analytics projects
- Review core concepts first: C008, C004, C006
Outcomes
- Work through a realistic scenario: A European industrial-equipment manufacturer's finance team needs multi-currency, multi-ledger P&L reporting in Datasphere, and the existing graphical views can no longer keep the year-over-year window calculations and the ledger-union logic the controllers require readable.
- Recognize and avoid the anti-pattern: Cursor-per-key loop instead of a set-based JOIN — 100,000 accounts become 100,000 round-trips; a load that should take minutes runs for hours and can saturate the shared HANA Cloud tenant.
- Apply the module's core decision: SQL view vs graphical view vs stored procedure — choose: SQL view for window functions and set operations that stay read-only (SQLScript table function when the read logic needs branches or loops); stored procedure only when the logic must write to a target table with branching or transaction control; avoid: Defaulting to a stored procedure for read-only transformation logic — it cannot carry the Fact semantic usage, so it cannot be the source of an Analytic Model, which a SQL view can be.
- Track mastery with the KPI: Query plan quality (target: 0 full COLUMN TABLE SCAN on tables >10M rows without a filtering predicate; red flag: Any HASH JOIN or table scan on stale statistics reaching production untested).
Full module with the Consultant plan — €19.90/month. The full module adds: the decision framework · the end-to-end scenario walkthrough · the KPI scorecard · the anti-patterns · the code blocks · the knowledge check · the diagrams.