Questions tagged [hana-sql-script]

The language for stored procedures and functions used in SAP HANA

SAP HANA SQL-Script is a collection of extensions to SQL. With those extensions you can create database procedures which will be stored on the SAP HANA database.

You can use sql-script via SAP-HANA-Studio which is an extension to eclipse.

Useful Links

121 questions
3
votes
2 answers

How to aggregate values from different rows in sql (HANA)?

I have a table of shipments defined like so (the table is stored in a HANA database, if relevant): CREATE COLUMN TABLE SHIPMENTS ( ShipmentID INT PRIMARY KEY, Received INT, Facility NVARCHAR(10), Item NVARCHAR(20) ); Here, the…
Kazim
  • 133
  • 5
3
votes
1 answer

Call stored procedure passing table type argument

I've created this stored procedure in HANA database which is taking two parameters, one is a table type and other is varchar. CREATE PROCEDURE UPDATE_GSTR(IN p_Input_Values "GSTR11".p_Input_Values , IN p_TRANS_ID VARCHAR(100)) Now I want to call…
nomaan
  • 33
  • 4
3
votes
2 answers

SQL capped, continuous sum

Assume a time series where we have one value per point in time. I have to calculate a continues sum by calculating the current value + the sum of the previous value. Tricky part however is, that the sum should be capped and hence not exceed a…
newBee
  • 1,182
  • 11
  • 27
3
votes
1 answer

Table totals to scalar variable in HANA

I'm currently working with writing database procedures for HANA via ABAP objects. I'd like to return a scalar value which is calculated from a selection rather than a table which the other developer would have to read from a table. I'd prefer that…
Bryan Abrams
  • 327
  • 4
  • 14
3
votes
2 answers

Convert T-SQL Declare statement to SAP HANA

I cannot seem to get the query with declare statement working in SAP HANA. Below I've put the original working T-SQL version and the HANA version output from the SQL converter. I've tried several versions and combinations, but every time I get…
user3797092
  • 31
  • 1
  • 2
2
votes
3 answers

How to create an average per partitions containing a maximum of 5 time dependent members?

My goal is to select an average of exactly 5 records only if they meet the left join criteria to another table. Let's say we have table one (left) with records: RECNUM ID DATE JOB 1 | cat | 2019.01.01 | meow 2 | dog |…
2
votes
1 answer

Calling SP throws "ABAP objects and DDIC objects must be declared in the METHOD statement"

I created a stored procedure in HANA and tried to call it through AMDP class. SP as below; PROCEDURE "SAPABAP1"."ATU.SF::TESTSPCALL" ( ) LANGUAGE SQLSCRIPT SQL SECURITY INVOKER READS SQL DATA AS BEGIN SELECT 1 FROM DUMMY; END; AMDP…
Thilina Nakkawita
  • 1,302
  • 3
  • 19
  • 33
2
votes
2 answers

Convert ABAP date to HANA date returning NULL if empty

My task is to convert a ABAP style date (i.e. 2017-11-20 which is represented as string "20171120") to a HANA date via sql script. This can easily be done by: select to_date('20171120','YYYYMMDD') from dummy; But there is another requirement: if…
Psio
  • 83
  • 2
  • 5
2
votes
1 answer

How to use a for loop to insert/alter multiple columns in a table?

I want to insert ten columns in a table in SQL HANA Procedure. The following is what I have done and it seems pretty okay to me but for some reason the system is throwing syntax error. What I want: 10 new columns named Col_1, Col_2..Col_10 each of…
Muskaan
  • 45
  • 8
2
votes
4 answers

HANA - Passing string variable into WHERE IN() clause in SQL script

Lets suppose I have some SQL script in a scripted calculation view that takes a single value input parameter and generates a string of multiple inputs for an input parameter in another calculation view. BEGIN declare paramStr clob; params = select…
Jenova
  • 21
  • 1
  • 1
  • 4
2
votes
2 answers

REGEXPR_REPLACE string

How to replace & in the below string: 'extends the functionality & of the & REPLACE function & by' with one, two and three respectively. In the end the result should be: extends the functionality one of the two REPLACE function three by
2
votes
2 answers

How to convert an invalid number column to a number on HANA?

I have a table with a string column. I convert this column to a number using the function TO_INTEGER(). Ist work fine. But If I Aggregate the converted column with the function SUM I got this error: SAP DBTech JDBC: [339]: invalid number: not a…
ayahya82
  • 294
  • 2
  • 5
  • 16
1
vote
2 answers

SQL Lag distinct - to the previous different value

I have the following simplified by many columns table. Person Period Cost_Center Previous_Cost_Center ----------- ---------------- ----------- ---------------------- 123 2019003 1 123 2019004 …
1
vote
2 answers

Generate data combinations for a column dynamically based on another column SQL

I have a table like below - COL1 COL2 ------------- 101 A 102 B 102 C 102 D 103 C 103 E I need to generate all possible combinations along with uniqueID for a set of unique values in COL1 shown as below - For example -…
Gowthi
  • 94
  • 6
1
vote
1 answer

Create a table in current user schema in HANA stored procedure?

I have some stored procedures that create tables that we use for validation purposes. Most of these tables get dropped on the procedure next execution. I created these procedures and when I run them they run fine, but my problem is that now we want…
1
2 3
8 9