Awk script with a urgent requirement

The Problem content is
pin (AND1) {
dir : output;
cap : hot;
tran: slew;
}
need to write a awk script which can search the Pin AND1 and then tran of the Group pin(AND1)
and then insert the code from the file "insert_code" .
insert_code file contents . It is a Big file the script should match the keywords #PIN (AND1) and #END
in the insert_code section and then insert the content in the file file1

#PIN (AND1)
timing () {
related_pin : GOOD ;
timing_type : setup_rising ;
rise_constraint (scalar) {
values ("TRIN") ;
}
fall_constraint (scalar) {
values ("BAD") ;
}
}
timing () {
related_pin : HSSRESYNCCLKOUT_int ;
timing_type : hold_rising ;
rise_constraint (scalar) {
values ("GOOD") ;
}
fall_constraint (scalar) {
values ("BAD") ;
}
}
}

#END

the new file file2 content after inserting the code should be :

pin (AND1) {
dir : output;
cap : hot;
tran: slew;
timing () {
related_pin : GOOD ;
timing_type : setup_rising ;
rise_constraint (scalar) {
values ("TRIN") ;
}
fall_constraint (scalar) {
values ("BAD") ;
}
}
timing () {
related_pin : HSSRESYNCCLKOUT_int ;
timing_type : hold_rising ;
rise_constraint (scalar) {
values ("GOOD") ;
}
fall_constraint (scalar) {
values ("BAD") ;
}
}
}
}

CAN ANYONE HELP ME OUT IN THIS URGENTLY

Thanks and Regards
Kshitij

Can you show us what have you tried so far and where you are stuck? With the examples given in this thread:

you should be able to find out how to insert the insert file at the desired position in your file.

awk '/PIN1/{f=1}f && /}/{print;system("cat insert_code");f=0;next}1' FILE > newfile

I tried with this but the Problem is the code is getting inserted like this

pin (PIN1 )
...
...
max_tran ...
}

insert_code file contents

actually it should be like this

pin (PIN1)

..

..

max_tran

insert_code file content

}

the insert_code file content has been modified and flags have been added with # so that we can match the pattersn which are with # and rest of the code will be inserted in the file 1 contents

Right now insert_code is getting inserted in the file 1 along with the keywords # which I need to avoid

Thanks and Regards
Kshitij Kulshreshtha

You are using the same code given for another situation. Devtakh has given you a explanation how the code works.

If it's so urgent for you, why don't you try to understand how it works and try to adjust the code?

You are expecting us to do the work for you, but that's not the way it works. We are all volunteering our time and expertise, we can give you the direction you need, but you have to put some effort into solving your own problem.

Regards