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
2
votes
1 answer

HANA: How can I set the seed on the RAND() function?

I am trying to fix the pseudo random numbers generated by the RAND() function in HANA sqlscript. I'm pretty sure it must be possible but the documentation is not very explicit. Thank you.
mik
  • 356
  • 1
  • 9
  • 24
2
votes
2 answers

How to get date and time separately in to two columns from a HANA unix timestamp field?

The unix timestamp value is coming to HANA via data services from MySQL DB. I can however find the date using the following statement but wanted to know if there are any built in functions in SAP HANA or in Data Services Designer which can do this…
Hashim
  • 23
  • 1
  • 1
  • 5
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
4 answers

SAP HANA SQL SCRIPT Select where in array

is there any possibility to use something like SELECT * FROM xy WHERE xy.field in :array; in SQL SCRIPT? Im using Abap Managed Datebase Procedures DECLARE arr NVARCHAR(5) ARRAY; IF i_where = '' THEN arr = ARRAY ('A1', 'A2', 'A3', 'A4', 'A5',…
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

SQL "IS NOT NULL" in SAP HANA SQLScript

Actually I tried to run a is null SQL Statement on a SAP HANA Database using the SAP HANA Studio. This does not work because SQLScript has no is not null or is null function. My statement looks like: Select * From MSEG Where KDAUF is…
user3665218
  • 25
  • 1
  • 1
  • 6
2
votes
1 answer

Add milliseconds to date in SQL, not seconds

I'm writing a procedure on the SAP HANA database (using SPS 07). In this procedure I save the current timestamp in a variable: vMyTimestamp := CURRENT_UTCTIMESTAMP; I know from HANA's SQL and System Views Reference that there are currently 5…
hoffman
  • 420
  • 5
  • 9
2
votes
2 answers

Scalar type not allowed : SQLSCRIPT

With limited knowledge of SQL, I write a procedure on HANA database and here is small part of my code. CREATE PROCEDURE _SYS_BIC.claims(OUT percent_value distinct_values) LANGUAGE SQLSCRIPT SQL SECURITY INVOKER READS SQL DATA AS…
Sangamesh Hs
  • 1,447
  • 3
  • 24
  • 39
1
vote
2 answers

MIN&MAX value finding with condition

I have a table: I need to get below result: The Code should select row where "Number" value is MIN. If there is "Unique_1" where "Unique_2" != MIN, then take columns where "Number" value is MAX. Current code: select T1.Unique_1, …
Petras
  • 581
  • 2
  • 7
  • 17
1
vote
1 answer

How to create a table variable for using in a JOIN?

Because SAP HANA doesn't support CTEs, I'd like to learn to use table variables in joins. I've found simple examples of using table variables in a join in SQL Server, like below: https://www.youtube.com/watch?v=2fc6YUCQSV8 I have not found any…
David Mays
  • 466
  • 4
  • 14
1
vote
1 answer

XML file as a stored procedure input parameter?

My current requirement has a scenario where I need to perform bulk inserts or batch inserts into two SAP HANA tables using a stored procedure as a reusable component. I wanted to know if there is a method in which I can accept a XML object as an…
1
vote
1 answer

Query on SQL Calculation

I am new to HANA, and was trying to write a SQL for finding standard deviation: select stddev(values) as stddev For example, the values are 6.8,10.2 and 3.4. When I am executing it in HANA, I am getting result as 3.39999. But when I try to calculate…
Ayn76
  • 21
  • 4
1
vote
0 answers

How to serialize, convert or access a Row Type Variable in SAP HANA

When creating a row-wise trigger in SAP HANA, a reference to a Row type variable can be obtained. E.g. in the example below :new_row and :old_row are row type variables. create trigger test_trigger after insert on test_table referencing new…
avanwyk
  • 700
  • 6
  • 13
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
10 11