SSC-EWI-OR0075

Labels in statements not supported

Severity

Medium

Some parts of the output code are omitted for clarity reasons.

Generate Procedures and Macros using JavasScript as the target language adding the following flag -t JavaScript or --PLTargetLanguage JavaScript

Description

Labels in statements not supported to reference a code block.

Example Code

Oracle:

IN -> Oracle_01.sql
--Additional Params: -t JavaScript
CREATE OR REPLACE EDITIONABLE PROCEDURE PROCEDURE1 
IS
BEGIN
    -- procedure body
    EXIT loop_b;
    -- procedure body continuation
END;

Snowflake Scripting:

OUT -> Oracle_01.sql
--Additional Params: -t JavaScript
--** SSC-FDM-OR0007 - SNOWFLAKE DOESN'T SUPPORT VERSIONING OF OBJECTS. DEVELOPERS SHOULD CONSIDER ALTERNATE APPROACHES FOR CODE VERSIONING. **
CREATE OR REPLACE PROCEDURE PROCEDURE1 ()
RETURNS STRING
LANGUAGE JAVASCRIPT
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "oracle",  "convertedOn": "07/16/2025",  "domain": "no-domain-provided" }}'
EXECUTE AS CALLER
AS
$$
    // REGION SnowConvert Helpers Code
    var RAISE = function (code,name,message) {
        message === undefined && ([name,message] = [message,name])
        var error = new Error(message);
        error.name = name
        SQLERRM = `${(SQLCODE = (error.code = code))}: ${message}`
        throw error;
    };
    var SQL = {
        FOUND : false,
        NOTFOUND : false,
        ROWCOUNT : 0,
        ISOPEN : false
    };
    var _RS, _ROWS, SQLERRM = "normal, successful completion", SQLCODE = 0;
    var getObj = (_rs) => Object.assign(new Object(),_rs);
    var getRow = (_rs) => (values = Object.values(_rs)) && (values = values.splice(-1 * _rs.getColumnCount())) && values;
    var fetch = (_RS,_ROWS,fmode) => _RS.getRowCount() && _ROWS.next() && (fmode ? getObj : getRow)(_ROWS) || (fmode ? new Object() : []);
    var EXEC = function (stmt,binds,opts) {
        try {
            binds = !(arguments[1] instanceof Array) && ((opts = arguments[1]) && []) || (binds || []);
            opts = opts || new Object();
            binds = binds ? binds.map(fixBind) : binds;
            _RS = snowflake.createStatement({
                    sqlText : stmt,
                    binds : binds
                });
            _ROWS = _RS.execute();
            if (opts.sql !== 0) {
                var isSelect = stmt.toUpperCase().trimStart().startsWith("SELECT");
                var affectedRows = isSelect ? _RS.getRowCount() : _RS.getNumRowsAffected();
                SQL.FOUND = affectedRows != 0;
                SQL.NOTFOUND = affectedRows == 0;
                SQL.ROWCOUNT = affectedRows;
            }
            if (opts.row === 2) {
                return _ROWS;
            }
            var INTO = function (opts) {
                if (opts.vars == 1 && _RS.getColumnCount() == 1 && _ROWS.next()) {
                    return _ROWS.getColumnValue(1);
                }
                if (opts.rec instanceof Object && _ROWS.next()) {
                    var recordKeys = Object.keys(opts.rec);
                    Object.assign(opts.rec,Object.fromEntries(new Map(getRow(_ROWS).map((element,Index) => [recordKeys[Index],element]))))
                    return opts.rec;
                }
                return fetch(_RS,_ROWS,opts.row);
            };
            var BULK_INTO_COLLECTION = function (into) {
                for(let i = 0;i < _RS.getRowCount();i++) {
                    FETCH_INTO_COLLECTIONS(into,fetch(_RS,_ROWS,opts.row));
                }
                return into;
            };
            if (_ROWS.getRowCount() > 0) {
                return _ROWS.getRowCount() == 1 ? INTO(opts) : BULK_INTO_COLLECTION(opts);
            }
        } catch(error) {
            RAISE(error.code,error.name,error.message)
        }
    };
    var FETCH_INTO_COLLECTIONS = function (collections,fetchValues) {
        for(let i = 0;i < collections.length;i++) {
            collections[i].push(fetchValues[i]);
        }
    };
    var IS_NULL = (arg) => !(arg || arg === 0);
    var formatDate = (arg) => (new Date(arg - (arg.getTimezoneOffset() * 60000))).toISOString().slice(0,-1);
    var fixBind = function (arg) {
        arg = arg instanceof Date ? formatDate(arg) : IS_NULL(arg) ? null : arg;
        return arg;
    };
    // END REGION

    /*     -- procedure body
        EXIT loop_b */
    // procedure body
    // procedure body
    ;
    // procedure body continuation
    ;
$$;

Recommendations

  • No end-user actions are required.

  • If you need more support, you can email us at [email protected]

Last updated