Add support for explicit cursor FOR loops when running in sql_mode=ORACLE:
The benefits of this syntax is:
- No declaration of the FOR variable rec is needed. The cursor FOR statement implicitly declares a record variable (i.e. a ROW type variable}} that has the same structure with the data returned by the cursor.
- No needs to do OPEN or CLOSE for the cursor. It's automatically opened before the loop, and is closed after the loop.
- No needs to do CLOSE from inside the FOR loop if one uses a GOTO statement from inside the loop. The cursor is closed automatically.
- No needs to do an explicit FETCH. The next row is automatically fetched in the beginning of every iteration.
- No needs to do an explicit EXIT to leave the loop when FETCH returned no data.
The fields of the implicitly declared record variable must be updatable:
Internally, the explicit cursor FOR LOOP will be transparently translated to:
- Declaration of a %ROWTYPE variable
- Simple LOOP with EXIT
So the block in the previous example will be effectively equal to: