Quantcast
Viewing all articles
Browse latest Browse all 6412

SQLScript - implicit variable declarations?

The following code comes from the SPS06 SQLScript manual.  I've got the following code to run just fine, but what confuses me is where the result set "rst" was declared.  I can change the name "rst" to anything and it still runs, so I am guess it must be declared implicitly?

 

Can anyone explain where and how rst was declared, and why the below does not give a compilation error?

  

CREATE PROCEDURE ARRAY_UNNEST_SIMPLE()

LANGUAGE SQLSCRIPT

SQL SECURITY INVOKER AS

BEGIN

  DECLARE id INTEGER ARRAY;

  DECLARE name VARCHAR(10) ARRAY;

 

  id[1] := 1;

  id[2] := 2;

  name[1] := 'name1';

  name[2] := 'name2';

  name[3] := 'name3';

  name[5] := 'name5';

 

  rst = UNNEST(:id, :name) AS ("ID", "NAME");

  SELECT * FROM :rst;

END;


Viewing all articles
Browse latest Browse all 6412

Trending Articles