How to create a user defined function in sybase?

sap-ase, user-defined-functions

Solution

I searched very much in web and other documents, I find that user-defined functions in Adaptive Server Enterprise 12 (ASE) must be implemented in Java. I decided to use a StordProcedure. It usage is a little hard but it supported in all version of Sybase.

see: http://www.sypron.nl/udf.html

Problem

I trying to define a function in sybase. I write this script: ``` CREATE FUNCTION GetUserGroup (userId int) RETURNS int BEGIN RETURN (10) END ``` but when I run this, I get this error: ``` >[Error] Script lines: 1-6 -------------------------- Incorrect syntax near the keyword 'BEGIN'. Msg: 156, Level: 15, State: 2 Server: NEWSERVER, Procedure: GetUserGroup, Line: 3 >[Error] Script lines: 1-6 -------------------------- A RETURN statement with a return status may only be used in a SQL stored procedure. Msg: 178, Level: 15, State: 1 Server: NEWSERVER, Procedure: GetUserGroup, Line: 4 [Executed: 10/13/09 11:01:29 AM IRST ] [Execution: 0/ms] ``` What can I do? Thanks

Original source