Cust_BC_POShipLineGetBomTree.sql 837 B

1234567891011121314151617181920212223242526
  1. /*********************************************************
  2. --¸ù¾Ý³ö»õ¼Æ»®ÐÐkey»ñÈ¡bomTree
  3. **********************************************************/
  4. If OBJECT_ID(N'Cust_BC_POShipLineGetBomTree',N'P') Is Not NULL
  5. Begin
  6. Drop Proc Cust_BC_POShipLineGetBomTree
  7. End
  8. GO
  9. Create Procedure Cust_BC_POShipLineGetBomTree
  10. @EntityKey bigint
  11. AS
  12. Begin
  13. declare @ParentID bigint =0;
  14. select @ParentID =ParentLine from PM_POShipLine where id=@EntityKey
  15. select a.ID,0 as ParentID,a.ItemInfo_ItemCode as ItemCode,a.ItemInfo_ItemName as ItemName,1 as Num from PM_POShipLine as a where ID=@ParentID
  16. union(
  17. select a.ID,a.ParentLine as ParentID,a.ItemInfo_ItemCode as ItemCode,a.ItemInfo_ItemName as ItemName,a.ReqQtyCU/b.ReqQtyCU as Num from PM_POShipLine as a left join PM_POShipLine as b on a.ParentLine=b.ID where a.ParentLine=@ParentID
  18. )
  19. End