INSERT INTO ctl_aplicativo ( SELECT 'rel_flx_faturamento_mensal_detalhado', 'Relatório de Faturamento e Despesa - Mensal Detalhado', 'FLX', 'R' FROM ctl_aplicativo WHERE aplinome = 'frm_bas_filial' AND (SELECT aplinome FROM ctl_aplicativo WHERE aplinome = 'rel_flx_faturamento_mensal_detalhado') IS NULL LIMIT 1); INSERT INTO ctl_grupo_x_direito ( SELECT grupousucod, 'rel_flx_faturamento_mensal_detalhado', 'T' FROM ctl_grupo_x_direito WHERE grupousucod IN (SELECT grupousucod FROM ctl_grupo_x_direito WHERE aplinome = 'rel_flx_faturamento_anual_pdf') AND grupousucod NOT IN (SELECT grupousucod FROM ctl_grupo_x_direito WHERE aplinome = 'rel_flx_faturamento_mensal_detalhado') GROUP BY grupousucod); DELETE FROM ctl_menu_nivel_dependencia WHERE aplicacao = 'rel_flx_faturamento_anual_pdf' AND aplicacao_nivel = 'rel_flx_faturamento_mensal_detalhado'; INSERT INTO ctl_menu_nivel_dependencia VALUES('rel_flx_faturamento_anual_pdf', 'rel_flx_faturamento_mensal_detalhado');