Last sc_exec_sql in for loop executed twice

I have a for-loop in after insert event ( and also after update event) in a multiple record form.

Within the for-loop I have 2 sc_exec_sql commands. From the SQL debug output, I traced that the last sc_exec_sql command will be executed twice.

Meaning,
for ($i = 0; $i < $record_cnt; $i ++) {

sc_exec_sql($sql1);

sc_execl_sql($sql2);
}

For loop count of 1, which ever is the 2nd sc_exec_sql statement, it will be executed twice while the first sc_exec_sql statement is executed once. (I have tested by swapping the sql statement and found the 2nd sc_exec_sql command will be run twice.)