I have created a script that formats all of my PL/SQL files into a simple file that has pairs of values, its quite hard to explain, i think it will be easier if you just look at the file;
PROCEDURE VALIDA_CAMBIO_GPR
TRUNCATE TMP_MOD_PVA
INSERT TMP_MOD_PVA
PROCEDURE AJUSTAR_FECHAS
INSERT PRO_TDA_VARLOG_ALM
PROCEDURE DEPURAR_CAMBIOS_GPR
PROCEDURE INC_EX_0001
INSERT CABECERA_ALARMAS
PROCEDURE INC_EX_0002
INSERT CABECERA_ALARMAS
PROCEDURE INC_EX_0003
INSERT CABECERA_ALARMAS
PROCEDURE INC_EX_0005
INSERT CABECERA_ALARMAS
PROCEDURE INC_EX_0007
INSERT CABECERA_ALARMAS
PROCEDURE INC_EX_0008
INSERT CABECERA_ALARMAS
PROCEDURE INC_EX_0009
INSERT CABECERA_ALARMAS
PROCEDURE INC_EX_0010
INSERT CABECERA_ALARMAS
PROCEDURE INC_EX_0011
INSERT CABECERA_ALARMAS
Ok, this file goes on for 4000 lines, but i dont need all of the lines, all i want are the pairs of TRUNCATE and INSERTS of the same table, so for example out of the last file i would only want to keep the name of the procedure containing the pair, and the pair. f.e
PROCEDURE VALIDA_CAMBIO_GPR
TRUNCATE TMP_MOD_PVA
INSERT TMP_MOD_PVA
As you can see, the TRUNCATE and INSERT affect the same table, there may also be more than one pair per procedure. How could i do this? I DO NOT WANT all the procedure's that dont have these pairs, and i also don't want any truncates of inserts that don't have their pair. Sorry for the bad explanation, if oyu have problems understanding just comment and i'll do my best to upgrade.
PD: Im using ksh.
Using
awk
: