Creating a Watcom SQL or Transact-SQL Function

Set up a new Watcom SQL or Transact-SQL function on an SAP Sybase IQ server.

Prerequisites
Database Version Function Privileges
SAP Sybase IQ 15.3 and 15.4 Watcom SQL or Transact-SQL function to be owned by self – you must have one of:
  • DBA authority
  • RESOURCE ADMIN authority

Watcom SQL or Transact-SQL function to be owned by any user – you must have DBA authority.

SAP Sybase IQ 16.0 Watcom SQL or Transact-SQL to be owned by self – you must have the CREATE PROCEDURE system privilege.

Watcom SQ or Transact-SQL function to be owned by any user – you must 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 Watcom-SQL or Transact-SQL.
    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 7. Otherwise, on the Specify Return Type page, select the type of value to return and define a name for the return variable. Click Next.
  7. On the SQL page, edit the code provided by the wizard.
    1. Define input parameters: name, type, and default value.
    2. Enter function statements.
    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.
  8. Click Finish.
Related tasks
Creating an External Java Function
Creating an External C/C++ Scalar or Aggregate Function
Deleting a Function
Generating Function DDL Commands
Viewing and Modifying a Function
Granting Function EXECUTE Permission
Revoking Function EXECUTE Permission
Authenticating a Login Account for a Managed Resource
Related reference
Function Privilege Summary