'@cNodeIDStr值的形式为:5,6,
If @cNodeIDStr<>'' --开始分解子节点串,并递归
Begin
--Set @cNodeIDStr=Left(@cNodeIDStr, Len(@cNodeIDStr)-1) --去掉最后一个逗号
While CharIndex(',', @cNodeIDStr) <> 0
Begin
Set @cNodeIDTmp = ''
--根据逗号提取子节点ID并且裁剪子节点ID串
Declare @sLen int
Set @sLen = CharIndex(',', @cNodeIDStr) --取第一个逗号的位置
Set @cNodeIDTmp = Left(@cNodeIDStr, @sLen-1) --取第一个逗号位置的ID
Set @cNodeIDStr = Right(@cNodeIDStr, Len(@cNodeIDStr)-@sLen) --取之后的ID串
If @cNodeIDTmp='' Or @cNodeIDTmp Is Null --不存在则跳过遁环
Begin
Continue
End
Else--存在则递归
Begin
Set @cNodeID = Cast(@cNodeIDTmp As bigint)
--print @cNodeIDTmp
--GRANT EXEC ON ProUpdateCompPath TO PUBLIC
Exec SeekdreamTree @TableName, @IDField, @CodeField, @cNodeID
End
End
End