PSQL Blocks
A statement answers one question. A PSQL block is what is written when the answer decides what happens next: a loop over rows, a condition, a variable, a call to a procedure. It runs in the editor like any other statement, with "Execute".
Running One
A block is written between begin and end; and is executed as one statement, however many statements it holds. The Results panel shows what the block finally selected, where it selected anything; a block which only writes shows the rows it affected on the status bar.
Seeing What It Does
A block which runs for minutes says nothing by itself, so two panels are worth having open beside it:
- DBMS Output collects what the block writes with
dbms_output.put_line, which is the cheapest way to follow a loop. The panel has to be switched on before the block runs; output written while it was off is not shown. - Progress draws the statements inside the block as they run, so a loop which is slower than expected shows which of its statements is the slow one.
Errors
A block which fails names the line it failed on, and "Goto Line" in the "Editor" tab jumps there; see Editing Text. The message code beside the text - itgenpse147, itgensyn304 - is what the forums and this documentation are indexed by.
A block is not a transaction. What the statements before the failure did stands, exactly as with Execute All over a document.
Where the Language Is Documented
The grammar of a block - the declarations, the control flow, the cursors, the exception handling - is documented under Procedural SQL and in the PSQL Block page. Blocks which are worth keeping are stored as PSQL objects in the data dictionary and are then callable by name from anywhere.