
set serveroutput on
set long 999999
set linesize 200
set pagesize 5000

/* --------------------------------

DUALITY VIEW

-------------------------------- */ 
-- convert
DECLARE
  schema_sql clob;
BEGIN
  schema_sql := dbms_json_duality.infer_and_generate_schema(
                json('{"tableNames"     : [ "PARSED_MARKDOWN_FILES" ],
                       "viewNames"      : [ "T" ],                       
                       "useFlexFields"  : false,
                       "updatability"   : true,
                       "sourceSchema"   : "APP_USER"}')
                );

  execute immediate schema_sql;

  dbms_json_duality.import(table_name => 'PARSED_MARKDOWN_FILES', view_name => 'T');

  execute immediate 'rename T TO V_PARSED_MARKDOWN_FILES';
END;
/


SELECT * FROM T_ROOT;
SELECT * FROM T_COMERCIOS;
SELECT * FROM T_BENEFICIOS_POR_NIVEL;
SELECT * FROM T_ACREDITACAO_REINTEGRO;
SELECT * FROM T_CUOTAS;
SELECT * FROM T_MEDIOS_PAGO;
SELECT * FROM T_PROMOCAO;
SELECT * FROM T_VIGENCIA;


-- duality view collection
SELECT json_serialize(data returning clob pretty) AS json_data 
FROM v_parsed_markdown_files;

