Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Parsing
Message
From
01/04/2021 18:52:13
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
01/04/2021 13:14:54
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01679440
Message ID:
01679456
Views:
39
>>Hi Kevin
>>
>>In message # 01679403 I am trying to get SQL Server to execute a command via SPT and if the command fails, send an error to VFP.
>>
>>The app I inherited is doing SQLEXEC without any checking of return values. I am building a little ??sqlexec in which I will check and re-establish a broken connection, check and retry for busy connections. I was prompted to use a transaction around the existing query.
>>
>>Can you advise?
>>
>>Thanks
>>
>>Mike
>
>Mike
>
>I'm not sure if this will help, but this is a function that has been working for a long time in my apps.
>I only use SPT.
>
>
>
>*-- Execute SQL Command and display errors, if any
>PARAMETERS pc_ConnHandle
>PRIVATE ll_return, ln_exec,la_error
>ll_return = .T.
>ln_exec = SQLEXEC(pc_ConnHandle)
>IF ln_exec < 1
>  ll_return = .F.
>  WAIT WINDOW "SQL ERROR Has Occurred "
>  = AERROR(la_error)
>  WAIT WINDOW la_error(1,2)
>ENDIF
>RETURN ll_return
>
Hi Bill

If this is a bit of SQL, what do you get in your la_Error?
	BEGIN TRY
		BEGIN TRANSACTION
		SELECT 1/0;
		COMMIT TRANSACTION
	END TRY
	BEGIN CATCH
		ROLLBACK TRANSACTION;
		THROW;
	END CATCH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform