任何表类型参数都是表参数,其类型在 DDL 期间定义为通配符,稍后在查询编译期间确定。
由于新的表类型支持,表参数的语法更改如下: 代码语法IN|OUT] TABLE(...)
以下示例说明了 any_table_type 参数在 DML 和 SELECT 语句中的一些用例。 示例代码create procedure myproc1(out ott table(...)) asbegin ott = select * from ctab1;end; -- use of nested call statements inside a proceduredrop procedure myproc1;create procedure myproc1(in itt table(...), out ott table(c int)) asbegin ott = select * from :itt;end; drop procedure myproc2;create procedure myproc2 asbegin it0 = select 1 c from ctab3; call myproc1(:it0, :ott);end; -- nested call with any table parametersdrop procedure subproc1;create procedure subproc1 (in itt table(...)) asbegin ott = select * from ctab1;end; drop procedure subproc2;create procedure subproc2(in itt table(...)) asbegin call subproc1(:itt);end; create procedure myproc2(in itt table(...)) asbegin lt0 = select * from :itt; lt1 = select * from :lt0; select * from :lt1, ctab1;end; any_table_type 参数也可用于具有不同语句的其他场景。 示例代码-- unnest statementcreate procedure unst_proc1(in itt table(a int), out ott table(...)) asbegin tmp = SELECT '1','2','3' as A from :itt; tmp2 = unnest(ARRAY_AGG(:tmp.a)); ott = select * from :tmp2;end; call unst_proc1(ctab1,?); -- ce functionscreate procedure ce_proc1 (out outtab table(...)) asbegin t = ce_column_table(temptable); outtab = ce_projection(:t, [b]);endcall ce_proc1(?); -- apply filtersCREATE PROCEDURE apply_p1(IN inputtab table(...), IN dynamic_filter_1 VARCHAR(5000)) asbegin outtab = APPLY_FILTER (:inputtab, :dynamic_filter_1); select * from :outtab;end; call apply_p1(ctab3, ' a like ''%fil%'' ');call apply_p1(ctab3, ' a = ''
any_table_type 参数可用于 SQLScript 语言中的过程和表 UDF 以及 AFL 语言中的过程,但有一些限制:
UDF 的输入参数,不支持作为返回参数
UDF 不支持 any_table_type 参数。
select * from in_any_table),则无法在 SQLScript 中调用该过程。