2

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', 'A6', 'A7'  );
  ELSE arr  = ARRAY ( i_where );
END IF;

e_result = SELECT DISTINCT
...
 WHERE sales.hierarchy in :arr

Thanks!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48

4 Answers4

0

Yes, you can use the [NOT] MEMBER OF function https://help.sap.com/saphelp_hanaplatform/helpdata/en/f6/66b950e5d34f84bb5b6f125e7e85c4/content.htm to check for matches within in an array.

If you want the array contents to be the filter for a column, then you first need to UNNEST it.

Lars Br.
  • 9,949
  • 2
  • 15
  • 29
0

You can do the following, though not sure of performance issues:

  1. Unnest the array to tbl:

    TABLE = UNNEST(ARRAY) as (FIELDNAME)
    
  2. Now put the select like this:

    SELECT * FROM (YOUR_TABLE) where FIELDNAME IN ( SELECT FIELDNAME FROM Table )
    
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
-1

Not directly, but you can use UNNEST to make a table out of it like so:

tbl = UNNEST(:arr);
SELECT .... WHERE sales.hierarchy in :tbl;
djk
  • 943
  • 2
  • 9
  • 27
-1

name the unnest field. tbl = UNNEST(:arr) as ("fieldname"); Try ... WHERE sales.hierarchy IN ( selec "fieldname" from tbl )

Jonas
  • 1