Issue several sql commands one after the other

I want to issue several sql commands in succession and give values from the first to the second.
As Example:
Select SEQUENCE.NevtVal Into Var1;
Insert into SF.Table1 ( ID, ID2, Value ) Values ( Var1, Var1, ‘Klaus’) ;

@umi You can create a stored procedure with these statements and then execute the procedure on Appsmith.

Alternatively, you can also write use JSObjects to call these separate queries one after the other and pass values from the first query to the second one

Do you have an example of how I can run SQL using JSObjects and get the return values into a public variable. Then I can process them again in another JSObject.

@umi you can use this to return the data from the stored procedure and then access it how you would a normal query {{}}