Creating an ASA User-Defined Function

To create an ASA user-defined function, you must have an ASA connection open. See Creating an ASA Connection Profile.

  1. In Database Explorer, select the Procedures & Functions folder. Right-click and select New|Function to open the User-Defined Function Creation wizard. The Create Function Skeleton wizard appears.

  2. Enter the following information in the appropriate fields.

    1. In the Name field, enter the new function name.

    2. Specify the SQL type you are using: either Watcom-SQL or Transact-SQL.

    3. If you choose Watcom-SQL, you can then choose either Deterministic Function or On Exception Return check box. Deterministic Function only works with Watcom-SQL. A function specified as not deterministic is re-evaluated each time it is called in a query. If you choose Transact-SQL, you may only select On Exception Resume. The On Exception Resume clause enables Transact SQL-like error handling to be used within a Watcom SQL syntax procedure.

  3. Enter a name in the Return Data field, and select the appropriate datatype from the drop-down.

  4. (Optional) Enter a description of the function in the Comments field and click Next.

    The Provide Optional Parameters and Variables Declaration page appears.

  5. Enter a parameter name in the Name column.

  6. Click the Datatype column to select a datatype from the drop-down.

  7. Specify any optional default value for the parameter you are defining.

  8. Declare variables, or click Finish if you have no variables to declare.

  9. In the Name column, enter any local variable names that you want to declare.

  10. Click the Datatype column to select a datatype from the drop-down list.

  11. Click Finish.

The function definition skeleton is inserted into SQL Editor and created in the database.

Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com