简体   繁体   English

如何引用雪花任务中调用的存储过程的返回值

[英]How to reference the return value of a stored procedure called within a task in snowflake

I have a user defined stored procedure that returns a VARIANT type in snowflake.我有一个用户定义的存储过程,它在雪花中返回一个VARIANT类型。 I would like to call this procedure from a task and log the return value into tables.我想从任务中调用此过程并将返回值记录到表中。

The task would look something like this:任务看起来像这样:

CREATE OR REPLACE TASK MY_TASK 
  SCHEDULE = '5 minute'
WHEN 
  SYSTEM$STREAM_HAS_DATA('MY_STREAM') 
AS
CALL MY_PROCEDURE();

/* This procedure could return the following metrics that I need to log.
{
  timestamp: 1234567890,
  rows_affected: 1234,
  success: true
}
*/

Is this possible or do I need to include logging in the procedure?这是可能的还是我需要在程序中包括登录?

Any single SQL statement, or a call to a stored procedure, executed when the task runs.任务运行时执行的任何单个 SQL 语句或对存储过程的调用。

You have to log it inside the stored procedure.您必须将其记录在存储过程中。

Reference: https://docs.snowflake.com/en/sql-reference/sql/create-task.html#required-parameters参考: https://docs.snowflake.com/en/sql-reference/sql/create-task.html#required-parameters

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM