Scriptcase sc_exec_sql with error handling

Anyone have some sample code on how to catch an error in sc_exec_sql before you get the error back from the application?

I found a post on @GunterEibl blog about it… but the post appears to be missing.

Thanks anyone that can help. I would like to try to catch the error and then rollback transactions using the catch.

1 Like

Hi,

You can try sc_select, there you have option to catch errors.

Hallo @yourguide,
sorry for the problem with my homepage.

This is the link to the English translation, which is now displaying OK:

I usually place the code in an internal function that can be used everywhere to replace sc_exec_sql.
Something like:

function asdw_exec_sql($befehl)
{
	sc_select(asdw_my_data,$befehl);
	if ({asdw_my_data} === false)
		{
			asdw_error({asdw_my_data_erro}. " aus SQL: " . $befehl);
		}
	else
		{
			return({asdw_my_data});
		}  }

I hope this will help.

Best
Gunter Eibl

Thanks @GunterEibl this is exactly what I was looking for.
Putting it into an internal function is great!

I assume you have a function called asdw_error that handles the error somehow?

1 Like