如何在sybase中创建用户定义的函数?
我试图在 sybase 中定义一个函数。我编写了这个脚本:
CREATE FUNCTION GetUserGroup (userId int)
RETURNS int
BEGIN
RETURN (10)
END
但是当我运行这个脚本时,我收到此错误:
>[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]
我能做什么? 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我在网上和其他文档中搜索了很多,我发现Adaptive Server Enterprise 12 (ASE)中的用户定义函数必须用Java实现。
我决定使用 StordProcedure。它的使用有点困难,但它在所有版本的 Sybase 中都支持。
请参阅:http://www.sypron.nl/udf.html
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
我没有发现代码有任何问题。您可以使用下面的代码重试 -
I doesn't find any thing wrong with the code. you can re-try with the code below-
试试这个......它会起作用
Try This ....it will work
这对我有用。
this worked for me.