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
4
votes
2 answers

how to join, if the text contains

I have 2 tables, say table A has 10 rows and table B has 100 rows and I want to perform a join, but the matching condition has to be where a column from A 'is like' a column from B meaning that anything can come before or after the column in B: For…
M Dogan
  • 41
  • 1
  • 3
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
  • 1
  • 5
3
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
  • 55
  • 2
  • 9
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,289
  • 1
  • 14
  • 31
3
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(). It works 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
  • 374
  • 3
  • 6
  • 18
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
  • 337
  • 1
  • 4
  • 16
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
3
votes
1 answer

CE Join on columns with different names

I have seen several examples to write CE functions. But, I have not come across any example where a join is performed on columns with different name. For example: With SQL: select T1.col1, T1.col2, T1.col3 , T2.col4, T2.col5, T2.col6 from …
Sangamesh Hs
  • 1,447
  • 3
  • 24
  • 39
2
votes
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 …
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 |…
wounky
  • 97
  • 1
  • 12
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…
Dumi
  • 1,414
  • 4
  • 21
  • 41
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
2 answers

How to get the last executed SQL statement in HANA?

I am inside a SQLScript procedure and would like to return the last SQL Statement from this procedure, like the last rowcount: /********* Begin Procedure Script ************/ BEGIN select 1 as "my_data" from dummy; select '::last_SQL' as…
Christian4145
  • 513
  • 1
  • 9
  • 31
2
votes
6 answers

Temporary tables in hana

it it possible to write script in hana that crate temporary table that is based on existing table (with no need to define columns and columns types hard coded ): create local temporary table #mytemp (id integer, name varchar(20)); create…
ronron555
  • 21
  • 1
  • 1
  • 3
1
2 3
10 11