SAP HANA SQLScript
SQLScript Basics: Syntax, Variables & NULL
27 flashcards · answers and spaced-repetition review in the KnowCard app
You want "first non-NULL of these values, else a fallback." COALESCE vs IFNULL — which, and how do they differ?
What is the DUMMY table, and why is it handy in the SQL console?
You must assign an empty but correctly-structured table (e.g. an AMDP ERRORTAB) or activation fails. How does the DUMMY trick do it?
What are the three ways to give a local table variable its type in a DECLARE?
Row 5 of test_null has NAME = NULL. Which of these two SELECTs returns row 5?
```
WHERE name LIKE 'P%'
-- or --
WHERE name NOT LIKE 'P%'
```
You want a column literally named STATUS. It seems to work sometimes and break others. What's going on, and how do you check?
Relational operators normally return TRUE or FALSE. What third result do they return, and when?
Can you assign a scalar subquery straight into a variable like lv = (SELECT max(id) FROM tasks);?
Predicates go in WHERE/IF/WHILE conditions. Name the main families and one keyword for each.
Your EXISTS subquery works in a WHERE clause but the parser rejects it in an IF condition. Which predicates are restricted in imperative IF/WHILE?
What does this return with str?
```
SELECT 5 + NULL AS a,
NULL || 'str' AS b
FROM dummy;
```
Why does this assignment fail?
```
lv_total = SUM(amount) FROM sales;
```
SQLScript is "SAP's SQL" — but what does it actually add on top of the ANSI SQL standard?
With DECIMAL columns netamount=50, grossamount=60, what does this expression evaluate to (no parentheses)?
```
grossamount / netamount * 100 - 100
```
SQLScript lets you push data-intensive logic into SAP HANA (code-to-data). What is the architectural price you pay for that speed?
Into which SQL category do GRANT, CREATE, and UPDATE each fall — DML, DDL, or DCL?
"Every SQLScript statement starts with a keyword and ends with a semicolon." What's the one exception to the keyword rule?
You indent a nested block in SQLScript to make it readable. Does that indentation change the program's meaning the way it would in Python?
A colleague comments out a line in a procedure using ABAP style — a leading *. Why won't the code run in the SQL console?
You create a table with column id (no quotes). Later you query SELECT ID FROM t and also SELECT "id" FROM t. Which one works?
You need to read an SAP BW generated table like /BI0/PMAT_PLANT. Why does SELECT * FROM /BI0/PMAT_PLANT fail, and what's the fix?
What appears in these two columns?
```
SELECT 0xFF AS hex,
-17.126E30 AS flt
FROM dummy;
```
Both columns display 2010-01-01. Are they the same data type?
```
SELECT '2010-01-01' AS a,
DATE'2010-01-01' AS b
FROM dummy;
```
Why is this table definition, though legal, considered dangerous?
```
CREATE TABLE t("ID" int,
" ID" int,
"ID " int);
```
SQLScript system variables start with ::. Name the common ones — and the visibility trap on each.
Inside a procedure you built a table variable tmp. Predict which of these two reads succeeds:
```
SELECT * FROM tmp;
SELECT * FROM :tmp;
```
You run a SELECT, then read ::ROWCOUNT to see how many rows it returned. What actually happens?
Start learning today
Free to start — download the app or use it in your browser.
