sc_redir syntax

Hello,
The following code is in OnAfterInsert on a form application. The sc_redir calls a tabs application that the form is part of.
When I have the sc_redir in place where it is, the sc_exec_sql never runs. Even though the sc_redir is after the sc_exec_sql.
Any idea why it would exhibit this behavior. My store procedure adds some records to the database. If the sc_redir is commented
out, all works as it should. If the sc_redir is there, the records never get added…Any help appreciated.

$check_sql =
“SELECT max(fin_date)
FROM fin_date WHERE cont_num = ‘[glo_cont_num]’
AND fin_date < ‘[glo_fin_date]’” ;
sc_lookup(rs, $check_sql);

if (isset({rs[0][0]}))
{
{olddate} = {rs[0][0]};
sc_exec_sql(“CALL get_prior_fs_detail([glo_cont_num],’{olddate}’,’{fin_date}’)”);
sc_redir(financial_tabs.php) ;
}
else
{
}

Yeah, I get that too when I use sc_redir onAfterInsert or onAfterUpdate. It gets redirected, but no query committed.
So now I use javascript to redirect after insert instead of sc_redir.

echo "<script>alert('Data saved');document.location.href='../your_app';</script>";

Thanks for the feedback and idea.

Hi Anjells and TheCoach,

I had the same issue, but found the solution in the manual:

[SIZE=14px]sc_commit_trans(“Connection”)[/SIZE]

In form applications, the events that can run this macro is dependent of the database update (onAfterInsert, onAfterUpdate, onAfterDelete, onBeforeInsert, onBeforeUpdate or onBeforeDelete), they are automatically protected through transaction control, since the connection is the same of the application.

If the user, in any of these events, use an application redirectioning (macro “sc_redir”) must before the redirect, use this macro to guarantee the transactions previously effected.

So, the following code will solve your issue (at least it solved mine) at onAfterInsert or onAfterUpdate:

sc_commit_trans();
sc_redir(’…’);

That seems to have fixed it…thank you!