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

SQL Anywhere 17 » SQL Anywhere Server - Programming

External environment support

Seven external runtime environments are supported. These include Embedded SQL and ODBC applications written in C/C++, and applications written in Java, JavaScript, Perl, PHP, or languages such as Microsoft C# and Microsoft Visual Basic that are based on the Microsoft .NET Framework Common Language Runtime (CLR).

While it is possible to call compiled native functions in a dynamic link library or shared object that is loaded by the database server into its own address space, the risk here is that if the native function causes a fault, then the database server crashes. Running compiled native functions outside the database server, in an external environment, eliminates these risks to the server.

The following is an overview of the external environment support.

  • The START EXTERNAL ENVIRONMENT and STOP EXTERNAL ENVIRONMENT statements are used to start or stop an external environment on demand. These statements are optional since external environments are automatically started and stopped when needed.

  • The ALTER EXTERNAL ENVIRONMENT statement is used to set or modify the location of an external environment.

  • The COMMENT ON EXTERNAL ENVIRONMENT statement is used to add a comment for an external environment.

  • Once an external environment is set up to be used on the database server, you can then install objects into the database and create stored procedures and functions that make use of these objects within the external environment.

  • The INSTALL EXTERNAL OBJECT statement is used to install a JavaScript, Perl or PHP external object (for example, a Perl script) from a file or an expression into the database. Once the external objects are installed in the database, they can be used within external stored procedure and function definitions.

  • The COMMENT ON EXTERNAL ENVIRONMENT OBJECT statement is used to add a comment for an external environment object.

  • To remove an installed JavaScript, Perl or PHP external object from the database, you use the REMOVE EXTERNAL OBJECT statement.

  • The CREATE PROCEDURE and CREATE FUNCTION statements are used to create external stored procedure and function definitions. They can be used like any other stored procedure or function in the database. The database server, when encountering an external environment stored procedure or function, automatically launches the external environment (if it has not already been started), and sends over whatever information is needed to get the external environment to fetch the external object from the database and execute it. Any result sets or return values resulting from the execution are returned as needed.