I have a file that contains the following format
delete from table1;
delete from table2;
insert into table1 (col1, col2) values (value1, value2)@
insert into table1 (col1, col2) values(value3, value4)@
insert into table2(col1, col2,col3) values(value1, value2, value3)@
etc
etc
This is in a single file, too big to edit.
The INSERT statements can be over multiple lines, and the terminator is always '@' sign.
There is a fixed number of tables and I know the name of these.
I have tried with awk using the following
awk '/^table1/{p=1}/^table2/{p=0;print}p' inputfile > outfile
awk '/^table2/{p=1}/^table3/{p=0;print}p' inputfile > outfile
This sort of works for anything apart from the first statement.
for the second statement it puts into the outfile
delete from table2
insert into table2(col1, col2,col3) values(value1, value2, value3)@
insert into table3........
But at least I can edit the file and remove table 3.
But there is probably a way of using awk to do this.
Thanks
Chris
