Shell Script to read specific lines in a file

I have a file with contents as follows

Record 1: Rejected - Error on table "DWO"."P2G_CUST_EVENTS".
ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated

Record 5: Rejected - Error on table "DWO"."P2G_CUST_EVENTS".
ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated

Record 6: Rejected - Error on table "DWO"."P2G_CUST_EVENTS".
ORA-00256: integrity constraint (DWO.CUST_EVENTS_PK) violated

Record 7: Rejected - Error on table "DWO"."P2G_CUST_EVENTS".
ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated

Now I need to find the record numbers against the rows having unique constraints. The data is present in 2 seperate lines, where the record number is present in the frist line and the Oracle Error in the subsequent line
I need to get the values
as follows in a file

1
5
7

because these are the record numbers of the rows having unique constraint errors.

I would like to know how to do it in shell scripting.

Try this code (test.tmp is the file that holds the records):

for i in $(grep -n unique test.tmp|cut -d: -f1)
do
i=$(($i-1))
sed -n "${i},${i}p" test.tmp|cut -d: -f1|cut -d" " -f2
done

Try...

awk 'BEGIN { FS = "[ :]" }
     $1 == "Record" { r = $2 }
     $1 == "ORA-00001" { print r }
    ' file1

Thank you very much for the response the code is working, however, the time it is taking is a bit more.

Thank you very much the code is working. Though I still need to improve on the performance, if you have any ideas to improve the performance do let me know.

maybe...

nawk 'BEGIN {
  FS=RS=""
}
$2 ~ /^ORA-00001/ { match($1,/[0-9][0-9]*:/); print substr($1, RSTART, RLENGTH-1)}' file1