Friday, April 10, 2015

Dexterity - generalized pass-through SQL Error Handler

Clean Code approach to pass-through SQL. Eliminates the need to constantly put this error handling in every time pass-through SQL is getting executed

inout long SQLConnection;

local string cantGetError = "Could not retrieve SQL error info.";
local integer nStatus;
local long sqlConnection, status;
local text SQL;
{SQL error information}
local long GPS_error_number, SQL_error_number;
local string SQL_error_string, ODBC_error_string;

if SQL_GetError(sqlConnection, GPS_error_number, SQL_error_number, SQL_error_string, ODBC_error_string) = OKAY then
throw SQL_EXCEPTION, 0, SQL_error_string;
throw SQL_EXCEPTION, 0, cantGetError;
end if;

No comments:

Post a Comment