Procedure DirectSQL(Datasource, SQLstatement)


With the procedure DirectSQL you can directly execute SQL statements within a data source.

     Datasource,         ! (input) a string expression
     SQLstatement        ! (input) a string expression



A string containing the name of a data source.


A string containing the SQL statement that must be executed within the data source.

Return Value

The procedure returns 1 if the SQL statement is executed successfully, or 0 if the execution failed. In case of failure, the corresponding error message can be obtained through the predefined string parameter CurrentErrorMessage.


  • If the SQL statement also produces a result set, then this set is ignored by AIMMS.

  • Note that the SQL dialect used by, for instance, Oracle, SQL Server and Microsoft Access may differ. If a call to DirectSQL fails because of such differences, you should inspect CurrentErrorMessage for further details.

See also

Calling stored procedures and executing SQL queries through AIMMS DATABASE PROCEDURES is discussed in Executing Stored Procedures and SQL Queries of the Language Reference.