This app is an All-In-One package to provide everything to HANA Lovers.
1. Courses on SAP HANA - Basics, Modeling and Administration
2. Multiple Quizzes on Overview, Modelling, Architeture, and Administration
3. Most popular articles on SAP HANA
4. Series of Interview questions to brushup your HANA skills
In this article we will show an example on - How to create and use Array inside procedures.
In SQLScript array can be declared using ARRAY function. Example 1:
Define an integer array that contains the numbers 1,2 and 3.
array_id INTEGER ARRAY := ARRAY(1, 2, 3);
Define an empty array of type INTEGER.
array_int INTEGER ARRAY;
The UNNEST function converts an array into a table. UNNEST returns a table including a row for each element of the array specified.
If there are multiple arrays given, the number of rows will be equal to the largest cardinality among the cardinalities of the arrays. In the returned table, the cells that are not corresponding to the elements of the arrays are filled with NULL values. Note: The UNNEST function cannot be referenced directly in FROM clause of a SELECT statement.
In this example we are going to create 4 arrays and create a table using the arrays. The output will be sent in output using a table type.
Create table type:
CREATE TYPE "<SCHEMA_NAME>".TT_PRODUCT_SALES AS TABLE(