Hi Italo,
for specifically this requirement, you can employ cursors and check after opening the cursor and fetching some data whether <cursorname>::NOTFOUND is true.
There's an example for this in the developer guide.
For just looping over the result set, you will be better off with the
FOR <row> as <cursor> DO
END FOR;
construct.
General error handling is currently not documented for SQLScript.
- Lars