--------------------------------------------------------
--  DDL for Function FNC_BRANCHES_QUERY
--------------------------------------------------------

  CREATE OR REPLACE EDITIONABLE FUNCTION "ENVX_OPER"."FNC_BRANCHES_QUERY" (
   pi_branches_jsonc  IN VARCHAR2
) RETURN CLOB AS
   v_query  CLOB;
   v_select VARCHAR2(4000);

BEGIN
	v_query := q'~SELECT branch_name, branch_name as id_branch FROM JSON_TABLE(JSON(:~'|| pi_branches_jsonc || q'~), '$.branch[*]'
	COLUMNS (
	  branch_name VARCHAR2(4000) PATH '$.name'
	));~';

	RETURN v_query;
END;

/
