Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » Application development using SQL


SQL statement execution in applications

The way you include SQL statements in your application depends on the application development tool and programming interface you use.

  • ADO.NET   You can execute SQL statements using various ADO.NET objects. The SACommand object is one example:
    SACommand cmd = new SACommand(
         "DELETE FROM Employees WHERE EmployeeID = 105", conn );

  • ODBC   If you are writing directly to the ODBC programming interface, your SQL statements appear in function calls. For example, the following C function call executes a DELETE statement:
    SQLExecDirect( stmt,
        "DELETE FROM Employees
         WHERE EmployeeID = 105",
        SQL_NTS );

  • JDBC   If you are using the JDBC programming interface, you can execute SQL statements by invoking methods of the statement object. For example:
        "DELETE FROM Employees
         WHERE EmployeeID = 105" );

  • Embedded SQL   If you are using embedded SQL, you prefix your C language SQL statements with the keyword EXEC SQL. The code is then run through a preprocessor before compiling. For example:
     'DELETE FROM Employees
      WHERE EmployeeID = 105';

  • Sybase Open Client   If you use the Sybase Open Client interface, your SQL statements appear in function calls. For example, the following pair of calls executes a DELETE statement:
    ret = ct_command( cmd, CS_LANG_CMD,
                      "DELETE FROM Employees
                       WHERE EmployeeID=105"
    ret = ct_send(cmd);

For more details about including SQL in your application, see your development tool documentation. If you are using ODBC or JDBC, consult the software development kit for those interfaces.

 Applications inside the database server
 See also