Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

sap-sqlscript

FreeNo executable scriptsNot checked

This skill should be used when the user asks to "write a SQLScript procedure", "create HANA stored procedure", "implement AMDP method", "optimize SQLScript…

secondskyby secondsky★ 511 GitHub stars16 installs in other catalogs

About this skill

SAP SQLScript Development Guide

When to Use This Skill

Use this skill when writing SQLScript procedures, anonymous blocks, table/scalar functions, AMDP methods, exception handlers, cursor logic, bulk operations, or HANA performance-sensitive database logic that should run close to the data.

For browser-based Datasphere or HANA Cloud SQL editor triage, use sap-browser-automation for manual in-app authentication, consent-gated Edge profile reuse, fresh Edge/CDP startup, auth-state bootstrap, and recovery. Load local references/edge-cdp-control.md for SQLScript-specific boundaries. Use CDP only for local UI inspection, console diagnostics, deployment messages, and approved screenshots; default database validation still belongs in SQL/HANA tooling.

Overview

SQLScript is SAP HANA's procedural extension to SQL, enabling complex data-intensive logic execution directly within the database layer. It follows the code-to-data paradigm, pushing computation to where data resides rather than moving data to the application layer.

Key Characteristics

  • Case-insensitive language
  • All statements end with semicolons
  • Variables use colon prefix when referenced (:variableName)
  • No colon when assigning values
  • Use DUMMY table for single-row operations

Two Logic Types

Type Description Execution
Declarative Pure SQL sequences Converted to data flow graphs, processed in parallel
Imperative Control structures (IF, WHILE, FOR) Processed sequentially, prevents parallel execution

Table of Contents


Container Types

1. Anonymous Blocks

Single-use logic not stored in the database. Useful for testing and ad-hoc execution.

DO [(<parameter_clause>)]
BEGIN [SEQUENTIAL EXECUTION]
  <body>
END;

Example:

DO
BEGIN
  DECLARE lv_count INTEGER;
  SELECT COUNT(*) INTO lv_count FROM "MYTABLE";
  SELECT :lv_count AS record_count FROM DUMMY;
END;

2. Stored Procedures

Reusable database objects with input/output parameters.

CREATE [OR REPLACE] PROCEDURE <procedure_name>
  (
    [IN <param> <datatype>],
    [OUT <param> <datatype>],
    [INOUT <param> <datatype>]
  )
  LANGUAGE SQLSCRIPT
  [SQL SECURITY {DEFINER | INVOKER}]
  [DEFAULT SCHEMA <schema_name>]
  [READS SQL DATA | READS SQL DATA WITH RESULT VIEW <view_name>]
AS
BEGIN
  <procedure_body>
END;

3. User-Defined Functions

Scalar UDF - Returns single value:

CREATE FUNCTION <function_name> (<input_parameters>)
RETURNS <scalar_type>
LANGUAGE SQLSCRIPT
AS
BEGIN
  <function_body>
  RETURN <value>;
END;

Table UDF - Returns table (read-only):

CREATE FUNCTION <function_name> (<input_parameters>)
RETURNS TABLE (<column_definitions>)
LANGUAGE SQLSCRIPT
READS SQL DATA
AS
BEGIN
  RETURN SELECT ... FROM ...;
END;

Data Types

SQLScript supports comprehensive data types for different use cases. See references/data-types.md for complete documentation including:

  • Numeric types (TINYINT, INTEGER, DECIMAL, etc.)
  • Character types (VARCHAR, NVARCHAR, CLOB, etc.)
  • Date/Time types (DATE, TIME, TIMESTAMP, SECONDDATE)
  • Binary types (VARBINARY, BLOB)
  • Type conversion functions (CAST, TO_ functions)
  • NULL handling patterns

Variable Declaration

Scalar Variables

DECLARE <variable_name> <datatype> [:= <initial_value>];

-- Examples
DECLARE lv_name NVARCHAR(100);
DECLARE lv_count INTEGER := 0;
DECLARE lv_date DATE := CURRENT_DATE;

Note: Uninitialized variables default to NULL.

Table Variables

Implicit declaration:

lt_result = SELECT * FROM "MYTABLE" WHERE status = 'A';

Explicit declaration:

DECLARE lt_data TABLE (
  id INTEGER,
  name NVARCHAR(100),
  amount DECIMAL(15,2)
);

Using TABLE LIKE:

DECLARE lt_copy TABLE LIKE :lt_original;

Arrays

DECLARE arr INTEGER ARRAY := ARRAY(1, 2, 3, 4, 5);
-- Access: arr[1], arr[2], etc. (1-based index)
-- Note: Arrays cannot be returned from procedures

Control Structures

IF-ELSE Statement

IF <condition1> THEN
  <statements>
[ELSEIF <condition2> THEN
  <statements>]
[ELSE
  <statements>]
END IF;

Comparison Operators:

Operator Meaning
Full SKILL.md on GitHub

Install sap-sqlscript in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

README.mdagents/openai.yamlreferences/advanced-features.mdreferences/amdp-integration.mdreferences/built-in-functions.mdreferences/data-types.mdreferences/edge-cdp-control.mdreferences/exception-handling.mdreferences/glossary.mdreferences/performance-guide.mdreferences/skill-reference-guide.mdreferences/syntax-reference.mdreferences/troubleshooting.mdtemplates/amdp-class.abaptemplates/amdp-procedure.sqltemplates/bulk-operations.sqltemplates/cursor-iteration.sqltemplates/procedure-with-error-handling.sqltemplates/scalar-function.sqltemplates/simple-procedure.sqltemplates/table-function.sql

FAQ

What does the sap-sqlscript skill do?

This skill should be used when the user asks to "write a SQLScript procedure", "create HANA stored procedure", "implement AMDP method", "optimize SQLScript performance", "handle SQLScript exceptions", "debug HANA procedure", "create table function", "inspect a browser-based Datasphere SQL editor with Microsoft Edge CDP", or mentions SQLScript, SAP HANA procedures, AMDP, EXIT HANDLER, or code-to-data paradigm. Comprehensive SQLScript development guidance for SAP HANA database programming including syntax patterns, built-in functions, exception handling, performance optimization, cursor management, and ABAP Managed Database Procedure (AMDP) integration.

How do I install the sap-sqlscript skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the sap-sqlscript skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare sap-sqlscript with