cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Script in dataservices to loop at SQL result set

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member750775
Discoverer
0 Kudos

Hello,

I want to transverse the table row by row and check the value of one column grouped by another column and assign the number range in desc order.

can anyone help please.

former_member187605
Active Contributor
0 Kudos

In pseudo code, too. I leave it to you to write the correct DS syntax .

$gv = SELECT min("/BIC/I_CST_FN") FROM "HANA_DB"."ZST0100"

while ($gv is not null)

     do

     DELETE FROM "OTHER_DB"."IN_TABLE WHERE FILE_NAME=$gv;

     $gv = SELECT min("/BIC/I_CST_FN") FROM "HANA_DB"."ZST0100" where "/BIC/I_CST_FN" > $gv;

     end

Former Member
0 Kudos

Hi Dirk

Thanks for your reply.

I will try to see if I can make that work

thanks once again. KR

Torben