BigQuery StoreProcedure returns a result-set(存储过程返回结果集)

StoreProcedure A 调用 StoreProcedure BA -> B),B返回一个结果集给A使用:

定义 StoreProcedure B :

CREATE OR REPLACE PROCEDURE `11864627-hsirnd-dev.POC_HK_DIPD_APP.TEST_SP`(pIndex STRING, OUT ResultSet ARRAY<STRUCT<indexAbbr STRING, RIC STRING, TradingDate DATE, TradingCurr STRING, Weight NUMERIC>>)
BEGIN

  DECLARE RES DEFAULT ARRAY(SELECT  STRUCT(indexAbbr, RIC, TradingDate, TradingCurr, RecappedWeight)  FROM `hsbc-11864627-hsirnd-dev.POC_HK_DIPD_IDM_DB01.idxBacktestDailyWeight` WHERE indexAbbr = pIndex);

  SET ResultSet = RES;

END;

调用 StoreProcedure B :

BEGIN 
  DECLARE RES ARRAY<STRUCT<indexAbbr STRING, RIC STRING, TradingDate DATE, TradingCurr STRING, Weight NUMERIC>>;
  CALL `11864627-hsirnd-dev.POC_HK_DIPD_APP.TEST_SP`('H40-2', RES);
  SELECT * FROM UNNEST(RES);
END;

 

posted @ 2023-02-14 10:57  雾中的-松  阅读(41)  评论(0编辑  收藏  举报