自定义函数的UPDATE问题


create table serial
(
serial long ,
tablename varchar(50)
)
函数
Create function AddOne
( @name varchar(50) )
RETURNS numeric
as

begin
declare @id as numeric
select @id=serial from serial where tablename=@name
update serial set serial=@id+1 where tablename=@name
return @id
end

报错:
在函数内不正确地使用了 'UPDATE'。
---------------------------------------------------------------

用户定义函数不能用于执行一组修改全局数据库状态的操作,只能对函数内的临时表进行INSERT,DELETE和UPDATE操作
---------------------------------------------------------------

改成存储过程吧

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus