A block consists of: declare: variables, cursors, ResultSets, custom exceptions, begin, exception, end
ResultSet
v/s cursor: For cursor, query is executed when cursor is opened, whereas, for ResultSet, the query is executed when it is assigned a query (or with default clause in declaration)
can be async
can be used to fetch data within the block by declaring a <csr> cursor for <rs>
can be returned by stored procedure that has a return type table as return table(<rs>); example
async queries are run in asynchronously in a child job
can be associated with ResultSet or can be associated independently
must be awaited or canceled
handling exceptions:
exception: followed by a series of when <exception> then statements
can handle declared exceptions or built-in (statement_error and expression_error)
available built-in variables: sqlcode, sqlerrm and sqlstate