F
fly555
Unregistered / Unconfirmed
GUEST, unregistred user!
我公司ERP(外购)的BOM用一个主从表实现,结构如下:表名:bom03(主表)主件:bom0101 varchar表名:bom04(从表)主件:bom0101 varchar(20)子件:bom0401 varchar(20)用量:bom0403 dec(16,3)主从表通过bom0101关联,其中BOM0401可以有下一阶.现在搞了这么一个自定义函数。CREATE FUNCTION getbom (@bom0101 varchar(20)) RETURNS @tbom table(bom0401 varchar(20),bom0403 decimal(16,3))ASbegindeclare @bom0401 varchar(20),@bom0403 decimal(16,3)declare my_cursor cursor forselect bom0401,bom0403 from bom04 where bom0101=@bom0101open my_cursorfetch next from my_cursor into @bom0401,@bom0403 while @@fetch_status=0begininsert into @tbom select @bom0401,@bom0403if exists(select *from bom04 where bom0101=@bom0401)insert into @tbom select *from dbo.getbom(@bom0401)fetch next from my_cursor into @bom0401,@bom0403endreturn end为什么用select dbo.getbom调用不成功呢?