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

151 questions
0
votes
1 answer

Get keys of json formatted values in SQL (hana)

There is a column that holds a json formatted value. id| statuses | --+---------------------------+ 1 | { "a": true, "b": false } | 2 | { "c": true } | Is it possible to turn it into a table as below? id | statusName |…
0
votes
0 answers

Create Dynamic Query in SAP using Table Function

I am trying to create Dynamic SQL query using Table Function, so that it can be consumed in ABAP CDS views. For same I have developed an ABAP Class & defined a method "Get_data". CLASS-METHODS get_data FOR TABLE FUNCTION ztablefunction. I am…
Urvish
  • 29
  • 2
  • 11
0
votes
0 answers

HANA select CURRENT_DATE output empty cell

I have a very simple problem with HANA SQL but I really can't understand the solution. My target is to output the current date. If I write the following query in HANA Studio, it output an empty cell SELECT current_date "current date" FROM…
Nicolaesse
  • 2,554
  • 12
  • 46
  • 71
0
votes
1 answer

How to do REDUCE calculation in AMDP method?

how can we achieve REDUCE like the below logic inside an AMDP method. lv_total = reduce tslxx9( init x type tslxx9 for lwa_out in lt_out where ( companycode = -bukrs and …
0
votes
1 answer

WITH RECURSIVE Common Table Expressions in SAP HANA

I'm really at a loss why I can't get this recursive CTE to work in HANA. We're on HANA 2 so from what I understand it should be supported if I put it in a procedure as SQLSCRIPT. We don't want to use the built in hierarchy functions since we're…
0
votes
1 answer

An SQL chalenge

I would like to solve this with pure SQL sentences in an AMDP method, I could solve this easily in ABAP, even in an AMDP method using loops, but as I said, I would like to solve this with SQL sentences, without use any kind of loops. Please take a…
Ronaldo
  • 21
  • 4
0
votes
2 answers

how to aggregate data based on condition

I would like to calculate the open quantity per item via comparing the creation and issue date in SQL , if the issue date is less than creation date on other rows for same item, quantity should be added to the open quantity for example row 3 has…
erkan
  • 3
  • 2
0
votes
2 answers

How to change Join type based on a parameter value?

In some of my procedures I'm passing parameter that should determine whether I need INNER or LEFT join but unfortunately I don't have an idea how can I implement it. The easiest solution of course is to have an IF statement and check for the…
Mati
  • 389
  • 3
  • 6
  • 16
0
votes
1 answer

SAP HANA SQLScript in DBeaver

I would like to ask if anyone has any idea/ know how to use SAP HANA SQLScript in DBeaver. Since SAP HANA supports some very useful features such as table variables etc, I would like to run following code (just a quick example): do BEGIN DECLARE…
Mati
  • 389
  • 3
  • 6
  • 16
0
votes
2 answers

SAP HANA CX_AMDP_EXECUTION_FAILED Dump SQL code 339 Date SQL

I have a sqlscript inside an AMDP class. I get a dump on the following statement: sel1 = select mandt, equnr, ROW_NUMBER() OVER ( PARTITION BY equnr ORDER BY equnr, idate, itime, mdocm) as rnum, to_date(idate) as idate, …
0
votes
1 answer

Error while selecting the calculation view through variables

I am facing one interesting issue while reading from a calculation view through variables ... the code is as follows: do begin declare lv_ww nvarchar(6); declare lv_quarter nvarchar(6); select "WORKWEEK","QUARTER" INTO lv_ww,lv_quarter from…
Saurav
  • 48
  • 6
0
votes
1 answer

SAP DBTech JDBC: [328]: invalid name of function or procedure: RECORD_COUNT. I don't understand why an error occurs when using RECORD_COUNT ()

I don't understand why an error occurs when using RECORD_COUNT (). Do you have a way to assign a record number value to an INT scalar variable? Here is my code: CREATE table tab (COL_A int); INSERT INTO tab VALUES (1); INSERT INTO tab…
An Pham
  • 17
  • 1
  • 7
0
votes
2 answers

How to change number formatting for Hana SQL query session or connection?

For our customers that use SAPB1 with HanaDB we execute the same query to pull data out (using the ADO.NET interface). Some have their regional system systems that appear to control numerical formatting according to their locale, etc. Say for…
Streamline
  • 2,040
  • 4
  • 37
  • 56
0
votes
1 answer

Return only the first parameter from stored procedure

How can I make it possible to return only the first parameter from a stored procedure with multiple OUT-parameters? Overview of Parameters Position Parameter Type 1 OUT 2 OUT So instead of create the CALL statement like this CALL…
MichaelW
  • 1
  • 1
0
votes
2 answers

Generate data combinations in 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 - There are 3 unique values in COL1, 6…