SQL control statements

Control statements are SQL statements that allow SQL to be used as a structured programming language. SQL control statements provide the capability to control the logic flow, declare and set variables, and handle warnings and exceptions. Some SQL control statements include other nested SQL statements.

SQL-control-statement
Read syntax diagramSkip visual syntax diagramassignment-statementCALL-statementCASE-statementcompound-statementFOR-statementGET DIAGNOSTICS-statementGOTO-statementIF-statementITERATE-statementLEAVE-statementLOOP-statementPIPE-statementREPEAT-statementRESIGNAL-statementRETURN-statementSIGNAL-statementWHILE-statement

Control statements are supported in SQL procedures, SQL functions, SQL triggers, and compound (dynamic) statements.