首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

SQL command not properly ended,该如何解决

2012-12-30 
SQL command not properly ended这是我的自定义的一个方法create function aa(@upperid int)returns @t ta

SQL command not properly ended
这是我的自定义的一个方法
create function aa(@upperid int)
returns @t table (id int,upperid int,level int)
as
begin
declare @i int
set @i=1
insert into @t
select *,@i from t where upperid=@upperid
while @@rowcount>0
begin
set @i=@i+1
insert into @t
select a.*,@i from t a left join @t b on a.upperid=b.id
where b.level=@i-1
end
return
end

我创建的一个简单的表
SQL> select * from t;
 
                                     ID                                 UPPERID
--------------------------------------- ---------------------------------------
                                      1                                       2
                                      3                                       2
                                      4                                       1
                                      5                                       3

最后我执行 select * from budgettest.aa(1) 就报错  就指教
[解决办法]
 select * from aa(1) 这么不行么
[解决办法]
select * from table(aa(1));
[解决办法]
发错版了吧,到sql server版问比较合适。
这不是oracle function的语句写法。

热点排行