mirror of
https://github.com/FlipsideCrypto/cosmos-models.git
synced 2026-02-06 13:56:46 +00:00
27 lines
597 B
PL/PgSQL
27 lines
597 B
PL/PgSQL
{% macro create_sp_get_cosmos_validators_realtime() %}
|
|
{% set sql %}
|
|
CREATE
|
|
OR REPLACE PROCEDURE streamline.sp_get_cosmos_validators_realtime() returns variant LANGUAGE SQL AS $$
|
|
DECLARE
|
|
RESULT variant;
|
|
row_cnt INTEGER;
|
|
BEGIN
|
|
row_cnt:= (
|
|
SELECT
|
|
COUNT(1)
|
|
FROM
|
|
{{ ref('streamline__validators_realtime') }}
|
|
);
|
|
if (
|
|
row_cnt > 0
|
|
) THEN RESULT:= (
|
|
SELECT
|
|
streamline.udf_get_cosmos_validators()
|
|
);
|
|
ELSE RESULT:= NULL;
|
|
END if;
|
|
RETURN RESULT;
|
|
END;$$ {% endset %}
|
|
{% do run_query(sql) %}
|
|
{% endmacro %}
|