Creating an External C/C++ Scalar or Aggregate Function

Set up a new external C or C++ aggregate function on an SAP Sybase IQ server.

Prerequisites
Database Version Function Privileges
SAP Sybase IQ 15.3 and 15.4 External C/C++ Scalar or Aggregate function to be owned by self or any user – you must have DBA authority.
SAP Sybase IQ 16.0 External C/C++ Scalar or Aggregate function to be owned by self – you must have all of:
  • CREATE PROCEDURE system privilege
  • CREATE EXTERNAL REFERENCE system privilege
External C/C++ Scalar or Aggregate function to be owned by any user – you must have the CREATE EXTERNAL REFERENCE system privilege. You must also have one of:
  • CREATE ANY PROCEDURE system privilege
  • CREATE ANY OBJECT system privilege
Task
  1. In the Perspective Resources view, select the resource, and select Resource > Administration Console.
  2. In the left pane, expand IQ Servers > Compiled Objects, and then select Functions.
  3. Click the arrow next to Functions and select New.
    The Create Function Wizard appears.
  4. On the Welcome page, specify:
    Option Description
    Select a resource for which the function will be created From the list, select the resource for which the function will be created.
    Which user or group/role do you want to own the function? From the list, select the user or role/group to own the function.
    What do you want to name the function? Enter a unique name for the new function; maximum of 128 characters.
    Which SQL dialect or language do you want to use? Select External C/C++ scalar or External C/C++ aggregate.
    Use SQL template (Optional) Select to insert a hardcoded SQL template and skip the wizard page for specifying a return type. You can also set a Watcom SQL function to be deterministic or nondeterministic.
  5. Click Next.
  6. If you chose to use the SQL template, skip to step 9. Otherwise, on the Specify Return Type page, select the type of value to return and whether to create a deterministic function. Click Next.
  7. On the Function Attributes page, specify the attributes of the function, including the names of its shared library file and descriptor function. Click Next.
  8. For External C/C++ aggregate only, on the Function Clauses page, configure clauses that control windows on the Function Clauses page. Click Next.
  9. On the SQL page, edit the code provided by the wizard.
    1. Define input parameters: name, type, and default value.
    2. If you chose to use the SQL template, replace the placeholder external name at the end of the query with a real name of the form functionDescriptorName@libraryName.
    3. Make any other changes needed to complete your function.
    4. (Optional) Enter a comment describing the function.
      Comments can include both HTML and Javadoc tags, so you can incorporate them into your generated database documentation.
  10. Click Finish.
Related tasks
Creating a Watcom SQL or Transact-SQL Function
Creating an External Java Function
Deleting a Function
Generating Function DDL Commands
Viewing and Modifying a Function
Granting Function EXECUTE Permission
Revoking Function EXECUTE Permission
Installing a Java Classes File into an SAP Sybase IQ Database
Authenticating a Login Account for a Managed Resource
Related reference
Function Privilege Summary