如何在存储过程中设置默认日期时间参数?
我在Sybase中声明了一个存储过程,其中一个参数是datetime类型。现在我想为这个日期时间指定一个默认值。
以下是声明:
create procedure Procedure
(
@fromDate datetime = getdate()
)
...
但是 Sybase 给我一个错误
Number (102) Severity (15) State (1) Server (SERVER) Procedure (Procedure) Incorrect syntax near '('.
Is it possible to do this?如果没有,有解决方法吗?
I have declared a stored procedure in Sybase, and one of the parameters is of type datetime. Now I want to assign this datetime a default value.
Here's the declaration:
create procedure Procedure
(
@fromDate datetime = getdate()
)
...
However Sybase is giving me an error
Number (102) Severity (15) State (1) Server (SERVER) Procedure (Procedure) Incorrect syntax near '('.
Is it possible to do this? If not, is there a workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在默认变量赋值中使用函数调用(正如您所发现的)。
将默认值设置为 Null,并在存储过程中首先进行赋值。
You can not use a function call in a default variable assignment (as you found out).
Set the default to Null, and put an assignment first thing in the stored procedure.