A
A
Alexander Batula2020-02-28 14:36:45
SQL
Alexander Batula, 2020-02-28 14:36:45

How to create custom function with declared variable in Vertica?

Hello everyone, I'm trying to create a custom function using variables in my function. Vertica does not support declared variables. Is there a workaround?
How can I implement this on vertica
I would be grateful for any hints or examples of use.

create or REPLACE FUNCTION itog_report_status.get_warn_lvl(day_count NUMERIC)
returns varchar
AS
DECLARE res varchar ;
BEGIN 
select status::varchar
from itog_reports_status.status_warn_level
where days = (
select MIN(days)
from itog_reports_status.status_warn_level
where day_count <= days);
RETURN COALESCE(res, 'RED')
END;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-02-28
@tsklab

Forum: How to declare a variable in Vertica?
Documentation: Variables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question