Ispirer Website Ispirer Capabilities: PostgreSQL Migration Free Trial

GOTO Conversion to PostgreSQL

PostgreSQL doesn’t support the GOTO statement, that’s why it requires significant code changes.

To emulate the GOTO operator when migrating from Microsoft SQL Server (or other databases that support this operator) to PostgreSQL, you can use the LOOP and CASE statements. Let's have a look in more detail: Create an auxiliary SWL_Label label and wrap the entire body of the procedure in it, not including statements after the labels. Following that generate an additional variable SWV_Label_value and initialize it with the value 'SWL_Start_Label'. Thus, the variable SWV_Label_value has the value 'SWL_Start_Label' before the first GOTO. When it is necessary to execute GOTO, change the value of this variable to the name of the label from the GOTO operator and proceed to the next iteration of SWL_Label. If SWV_Label_value doesn’t change by the end of the procedure, then the GOTO operator has not been executed. Afterwards, generate an additional case statement to check each SWV_Label_value value and execute the corresponding code from the specified label.

For example:

Microsoft SQL Server PostgreSQL

The result:

Microsoft SQL Server PostgreSQL

If you have any questions or face any difficulties, please contact our support team: