A return statement was added at the end of the label section to ensure the same execution flow
This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.
Severity
Medium
Description
When a Goto statement is replaced with a Label section and it does not contain a return statement, then one is added at the end of the section to ensure the same execution flow.
In BTEQ after a Goto command is executed the statements that are between the goto command and the label command with the same name are ignored. So, to avoid those statements to be executed the label section should contains a return statement.
In addition, is worth value mentioning the Goto command skips all the other statements except for the Label with the same name, where is when the execution resumes. Therefore, the execution will never resume in a label section defined before the Goto command.
EXECUTEIMMEDIATE$$DECLARE STATUS_OBJECT OBJECT;BEGIN/*** MSC-ERROR - MSCEWI1037 - TRANSLATION FOR SCRIPT STATEMENTS IS PLANNED TO BE DELIVERED IN THE FUTURE ***//*.LOGON dbc,dbc;*/BEGINSELECT'STATEMENTS'; STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT); EXCEPTIONWHEN OTHER THEN STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);END;/*** MSC-ERROR - MSCEWI2071 - GOTO LABEL_B WAS REPLACED WITH THE LABEL SECTION WITH THE SAME NAME ***//*.label LABEL_B*/BEGINSELECT'LABEL_B STATEMENTS'; STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT); EXCEPTIONWHEN OTHER THEN STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);END; /*** MSC-ERROR - MSCEWI2070 - A RETURN STATEMENT WAS ADDED AT THE END OF THE LABEL SECTION LABEL_B TO ENSURE THE SAME EXECUTION FLOW ***/
RETURN0;BEGINSELECT'IGNORED STATEMENTS'; STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT); EXCEPTIONWHEN OTHER THEN STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);END;/*** MSC-WARNING - MSCEWI1002 - REMOVED NEXT STATEMENT, NOT APPLICABLE IN SNOWFLAKE. ***//*.label LABEL_B*/BEGINSELECT'LABEL_B STATEMENTS'; STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT); EXCEPTIONWHEN OTHER THEN STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);END;END$$