f2s_esql_last_error¶

Applies to: Oracle, MS SQL, MySql/MariaDB, PostgreSQL Drivers

Syntax

**There is no set_attribute.  This attribute is read only.**
get_attribute f2s_esql_last_error of {DriverID} to {variable}

Parameter

Description

DriverID

The ID of the driver for which this applies. In most cases, you should use _f2s_ActiveDriverID.

variable

String variable to hold the error.

Description

Getting this read only attribute returns an error message from the last executed SQL statement. If the statement is executed with no errors, an empty string will be returned.

Examples

get_attribute

Struct tCustomer
    String Name
    String Addr
End_Struct

//In this case, sError will be blank
procedure GoodSQLStatment
  String sSQL sError
  tCustomer MyCustomers
  Variant [] vRow

  f2s_esql_create_stmt "select Name, Address from Customer where Customer_Number=1"
  f2s_esql_prepare_stmt
  f2s_esql_execute_stmt
  Get_Attribute f2s_esql_last_error of _f2s_ActiveDriverId to sError
  If (sError<>"") Showln (sFormat("Error: %1", sError))
  Else Begin
      f2s_esql_get_row vRow
      Get LoadStructFromArray of mdsStructAnalyzer MyCustomers vRow to MyCustomers
      Showln (SFormat("Customer %1, at address %2", MyCustomers.Name, MyCustomers.Addr))
  End
end procedure


//In this case, the error will be an Invalid column name (Customer_ID)
procedure BadSQLStatment
  String sSQL sError
  tCustomer MyCustomers
  Variant [] vRow

  f2s_esql_create_stmt "select Name, Address from Customer where Customer_ID=1"
  f2s_esql_prepare_stmt
  f2s_esql_execute_stmt
  Get_Attribute f2s_esql_last_error of _f2s_ActiveDriverId to sError
  If (sError<>"") Showln (sFormat("Error: %1", sError))
  Else Begin
      f2s_esql_get_row vRow
      Get LoadStructFromArray of mdsStructAnalyzer MyCustomers vRow to MyCustomers
      Showln (SFormat("Customer %1, at address %2", MyCustomers.Name, MyCustomers.Addr))
  End
end procedure

Related Attributes

Replaces: Command SQL_ERROR_MESSAGE