Skip to Content
0
Former Member
Sep 01, 2015 at 02:43 PM

SQL Script in dataservices to loop at SQL result set

1366 Views

Hi,

I would like to create a script in data services that can perform the psedo code below. However I have no clue how to make the loop functionality so that I loop at every single record that the select statement returns.

Psedo:

SELECT DISTINCT "/BIC/I_CST_FN" FROM "HANA_DB"."ZST0100"

Loop at the result set returned by above statement, for each result record

DELETE FROM "OTHER_DB"."IN_TABLE WHERE FILE_NAME="/BIC/I_CST_FN"

So basically in the target HANA_DB I have a table (ZST0100). Based on the distinct filenames listed in ZST0100 I would like to delete records in the IN_TABLE which is located in OTHER_DB.

I know I can use this statement to delete: sql('OTHER_DB','DELETE FROM IN_TABLE WHERE FILENAME=abcabcabc'); However I have no idea about how to make the loop, hope you can help.

Thanks in advance.

KR

Torben