CREATE FUNCTION dbo.GetOnlineBookTypeKeysForWare (@AWareNumber INT )  

--Created AV 20060711 used in OnlineDelivery in management ware.

RETURNS VARCHAR (100)
BEGIN 

  DECLARE @Return Varchar (200)
  DECLARE @OnlineBookTypeNumber INT

  SET @Return = ''
  DECLARE OnlineCur CURSOR FORWARD_ONLY FOR
  SELECT OnlineBookTypeNumber FROM OnlineBookTypeWareXTab WITH (NOLOCK)
  WHERE WareNumber = @AWareNumber
  OPEN OnlineCur
  FETCH NEXT FROM OnlineCur  INTO @OnlineBookTypeNumber
  WHILE  (@@FETCH_STATUS <> -1)
  BEGIN
    IF @Return <> ''
      SET @Return = @Return + ','
    SET @Return = @Return + CONVERT(VARCHAR(2),@OnlineBookTypeNumber)
    FETCH NEXT FROM OnlineCur  INTO @OnlineBookTypeNumber
  END
  CLOSE OnlineCur
  DEALLOCATE OnlineCur


Return @Return

END

