我们可以使用 sql 通过存储过程 return 一个在雪花上有大约 270 列的 table 吗?语法如下
Can we return a table with about 270 columns on snowflake through a stored procedure using sql? Syntax is below
我们可以使用 sql 作为语言在 Snowflake 中 return table 吗?如果可能,正确的语法是什么?
create or replace procedure sp()
returns table ()
language sql
as
$$
declare
accountingMonth :=(select dateadd(month,case when day(current_timestamp())<=10 then -1 else 0 end,dateadd(month,0,date_trunc('month',current_date()))));
endmonth :=(select dateadd(month,1,dateadd(month,case when day(current_timestamp())<=10 then -1 else 0 end,dateadd(month,0,date_trunc('month',current_date())))));
currmonth date default accountingMonth;
begin
create or replace temporary table sa as (
select col1,col2, col3,datecol,....col270
from table2
where datecol = :accountingmonth
);
end;
select * from sa;
$$
是的,可以使用 RESULTSET
从存储过程 return table
CREATE OR REPLACE PROCEDURE sp()
RETURNS TABLE(col1 INTEGER, ...)
LANGUAGE SQL
AS
BEGIN
-- ...
let RESULTSET DEFAULT (select * from sa);
RETURN TABLE(res);
END;
我们可以使用 sql 作为语言在 Snowflake 中 return table 吗?如果可能,正确的语法是什么?
create or replace procedure sp()
returns table ()
language sql
as
$$
declare
accountingMonth :=(select dateadd(month,case when day(current_timestamp())<=10 then -1 else 0 end,dateadd(month,0,date_trunc('month',current_date()))));
endmonth :=(select dateadd(month,1,dateadd(month,case when day(current_timestamp())<=10 then -1 else 0 end,dateadd(month,0,date_trunc('month',current_date())))));
currmonth date default accountingMonth;
begin
create or replace temporary table sa as (
select col1,col2, col3,datecol,....col270
from table2
where datecol = :accountingmonth
);
end;
select * from sa;
$$
是的,可以使用 RESULTSET
从存储过程 return tableCREATE OR REPLACE PROCEDURE sp()
RETURNS TABLE(col1 INTEGER, ...)
LANGUAGE SQL
AS
BEGIN
-- ...
let RESULTSET DEFAULT (select * from sa);
RETURN TABLE(res);
END;