Creating an ASE User-Defined Function

Create a user-defined function in ASE.

Prerequisites 

Be sure the data server that contains the user-defined function is running, and that you have created and established a connection to the data server.

  1. In the Databases folder in Enterprise Explorer, under the database connection profile, expand the Databases folder, expand the tree for a database, and then expand the tree for the appropriate schema owner.
  2. Right-click the User Defined Functions folder, and select New > User Defined Function .
  3. Enter the new function Name.
  4. Select the Return Data datatype.
  5. Select With Compile to indicate that a new plan is created each time the function is first referenced in a SQL statement. Use this option if you expect an atypical execution of the function that requires a new plan.
  6. (Optional) Enter a description in the Comments field.
  7. Click Next.
  8. Enter a parameter Name.
  9. Select a Datatype.
  10. Specify any optional default value for the parameter you are defining.
  11. Declare variables, or click Finish.
  12. In the Name column, enter any local variable names that you want to declare.
  13. Select a Datatype.
  14. Click Next and specify save and execution properties.
    Field Description
    Generate Script Generate a SQL file for the object.
    Enter or Select the Parent Folder Specify an existing project or create a new project in which to save the SQL file.
    File Name Enter the file name in which to store the SQL code.
    Execute Immediately Execute the SQL code immediately. If you do not select this option, you must execute the SQL file later to create the object.
    Open in Editor After Creation Create the object and open it in its associated editor.
  15. Click Finish to create the user-defined function.

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.