aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_get_reports_option_js
Parameters
Name
Type
Mode
report_id
integer
IN
is_batch_report
boolean
IN (DEFAULT false)
option_values
jsonb
IN (DEFAULT NULL)
Definition
declare json_options jsonb; json_result jsonb = '[]'; param jsonb; _state TEXT; _detail TEXT; _hint TEXT; _context TEXT; _result_code TEXT; _result_msg TEXT; _msg_code TEXT; begin json_options := (select report_options from dblink(fn_conn_authen(), format('Select "options" from reports where id = %L', report_id)) as params(report_options jsonb)); FOR param IN SELECT jsonb_array_elements(json_options->'parameters') LOOP json_result := json_result || sp_parse_report_param(param, is_batch_report, option_values->(param->>'name')); END LOOP; RETURN fn_result_success(json_build_object('parameters', json_result)); EXCEPTION WHEN OTHERS THEN GET STACKED DIAGNOSTICS _state = RETURNED_SQLSTATE, _result_msg = MESSAGE_TEXT, _detail = PG_EXCEPTION_DETAIL, _hint = PG_EXCEPTION_HINT, _context = PG_EXCEPTION_CONTEXT; RETURN fn_handle_error(_state, _result_msg, _detail, _hint, _context, 'sp_get_reports_option_js', jsonb_build_object( 'report_id', report_id, 'parameter', json_options->'parameters' ) ); END;