Into Helper

The into function is used to extract the resulting rows from a subquery or from a select into statement.

Fetch Function

The INTO helper uses a fetch function to get the row from a resulting query. The definition of the Fetch Function is described below.

var fetch = (count,rows,stmt) => 
(count && rows.next() && Array.apply(null,Array(stmt.getColumnCount())).map((_,i)
=> rows.getColumnValue(i + 1))) || [];

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

Into Sample Usage

Teradata

IN -> Teradata_01.sql
-- Additional Params: -t JavaScript
REPLACE PROCEDURE SubQuerypoc ()
BEGIN

DECLARE monat INTEGER;
SET monat      = (SELECT column1
             FROM table1);
END;

Snowflake output

OUT -> Teradata_01.sql
CREATE OR REPLACE PROCEDURE SubQuerypoc ()
RETURNS STRING
LANGUAGE JAVASCRIPT
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"teradata"}}'
EXECUTE AS CALLER
AS
$$
    // SnowConvert Helpers Code section is omitted.
    
    var MONAT;
    EXEC(`(SELECT column1 FROM table1)`,[]);
    var subQueryVariable0;
    [subQueryVariable0] = INTO();
    MONAT = subQueryVariable0;
$$;

Into Helper function Definition

var INTO = () => fetch(ROW_COUNT,_ROWS,_RS);

Known Issues

No issues were found.

No related EWIs.

Last updated