Table of Contents

Trapping and using EuSQL error information

When everything works, EuSQL returns a sequence. If there is a problem, a positive integer error code is returned. Following is the descriptions of errors:

The best method for retrieving error information is through the function get_sql_err(), which returns extended error information, as well as the standard error message (see description in API). It is recommended that you call get_sql_err() rather than accessing EUSQL_ERR_MSG (see below), since you'll get a more detailed description of the error.

EuSQL has predefined error strings, which can be accessed through EUSQL_ERR_MSG:

global constant
                "EuSQL Error: OPERATION FAILED",
                "EuSQL Error: ERROR IN 'WHERE' CLAUSE",
                "EuSQL Error: INVALID FIELD",
                "EuSQL Error: JOIN ERROR",
                "EuSQL Error: INVALID TABLE",
                "EuSQL Error: SYNTAX ERROR"


object sql
 sql = parse_sql( sql )
if atom(sql) then
  puts(1, get_sql_err( sql ) )
end if

  • type EUSQLRESULT( object e )   User defined type
  • proc eusql_err_out( integer fn )   
  • proc eusql_true_typecheck( integer new_setting )   
  • func get_sql_err( integer errnum )   

    Table of Contents

    ( object e )

    User defined type

    Category: Errors

    Variables of type EUSQLRESULT are sequences, unless there is an error, at which point the variable will contain a positive integer. If 'with type' is specified, typechecking will fail, and the error will be output to either a user specified routine or to the output stream specified by eusql_err_out(). If you call eusql_true_typecheck( 0 ), then your program will not crash when a EUSQLRESULT is an integer. EuSQL will pass control back to you. If 'without type' is specified, EuSQL will not automatically catch errors.

    See Also: eusql_err_out, eusql_true_typecheck, get_sql_err

    Table of Contents

    ( integer fn )

    Category: Errors

    Redirects EuSQL typecheck errors. If fn is positive, then errors are output to file number fn. If fn is negative, then -fn is the routine id of a user specified callback procedure. EuSQL will call this procedure if a typecheck fails. The parameter will be the integer EUSQL_ERR_ code. When the callback procedure returns, the typecheck will fail unless typechecking was previously turned off using eusql_true_typecheck(). The default value is 1, which ouputs error messages to the console.

    See Also: EUSQLRESULT, eusql_true_typecheck, get_sql_err

    Table of Contents

    ( integer new_setting )

    Category: Errors

    Indicates whether typechecks for variables of type EUSQLRESULT will return a value of zero. This is independent of any calls to 'with type' or 'without type'. new_setting should be a boolean value. If set to 0, EUSQLRESULT typechecks that fail will not crash if typechecking is on.

    See Also: EUSQLRESULT, eusql_err_out, get_sql_err

    Table of Contents

    ( integer errnum )

    Category: Errors

    Use this to get a text representation of the error returned. It also includes any extended error information beyond the standard error.

    See Also: EUSQLRESULT, eusql_err_out, eusql_true_typecheck