CREATE PROCEDURE dbo.TProductCopyFieldToPeriod @OldProductNumber int,  @FieldType smallint, @Persons smallint, @FieldNumber smallint, @FieldKeyNumber int, @SourceDate datetime, @DestStartDate datetime, @DestEndDate datetime AS
SET NOCOUNT ON
/*
  KJ 20141219: Ext: Changed datatype for prices. Handle amount > 214.000.
  2008 0220 FIX for referential integriety problems (producktprice -- packet table)  
  20050504 JP Removed ProductPriceNumber field and changed money fields to smallmoney
  20050105 JP Removed update of only 1 roomtype in addon fields (NB! FieldKeyNumber : RoomTypeNumber for FieldType 0, 1, 2)
  20030507 JP Removed update of only 1 roomtype in package fields
  Sidst rettet 231002 AV - varchar til moeny
  021202 JP addons

  FieldType : 0 Adult PriceCol (1-9)
                    1 Child1 PriceCol (1-9)
                    2 Child2 PriceCol (1-9) 
                    3 Adult AddonCol (1-9) (1-3)
                    4 Child1 AddonCol (1-9) (1-3)
                    5 Child2 AddonCol (1-9) (1-3)
                    6 Adult PacketCol (1) (1-3)

  Persons : Pax 1-9

  FieldNumber: RoomType Col (Depends on FieldKeyNumber, Addon Col (0-2), Packet Col (0-2)

  FieldKeyNumber : RoomTypeNumber for FieldType 0, 1, 2

*/

-- Declare all fields in ProductPrice
Declare @ProductNumber Int
Declare @DateStamp VarChar (8)
Declare @RoomtypeNumber int

Declare @AdultPrice1 money
Declare @AdultPrice2 money
Declare @AdultPrice3 money
Declare @AdultPrice4 money
Declare @AdultPrice5 money
Declare @AdultPrice6 money
Declare @AdultPrice7 money
Declare @AdultPrice8 money
Declare @AdultPrice9 money
Declare @Children1Price1 money
Declare @Children1Price2 money
Declare @Children1Price3 money
Declare @Children1Price4 money
Declare @Children1Price5 money
Declare @Children1Price6 money
Declare @Children1Price7 money
Declare @Children1Price8 money
Declare @Children1Price9 money
Declare @Children2Price1 money
Declare @Children2Price2 money
Declare @Children2Price3 money
Declare @Children2Price4 money
Declare @Children2Price5 money
Declare @Children2Price6 money
Declare @Children2Price7 money
Declare @Children2Price8 money
Declare @Children2Price9 money
Declare @AdultArrivalAddon smallmoney
Declare @AdultStayAddon smallmoney
Declare @AdultDepartureAddon smallmoney
Declare @Children1ArrivalAddon smallmoney
Declare @Children1StayAddon smallmoney
Declare @Children1DepartureAddon smallmoney
Declare @Children2ArrivalAddon smallmoney
Declare @Children2StayAddon smallmoney
Declare @Children2DepartureAddon smallmoney


Declare @AdultArrivalAddon2 smallmoney
Declare @AdultStayAddon2 smallmoney
Declare @AdultDepartureAddon2 smallmoney
Declare @Children1ArrivalAddon2 smallmoney
Declare @Children1StayAddon2 smallmoney
Declare @Children1DepartureAddon2 smallmoney
Declare @Children2ArrivalAddon2 smallmoney
Declare @Children2StayAddon2 smallmoney
Declare @Children2DepartureAddon2 smallmoney
Declare @AdultArrivalAddon3 smallmoney
Declare @AdultStayAddon3 smallmoney
Declare @AdultDepartureAddon3 smallmoney
Declare @Children1ArrivalAddon3 smallmoney
Declare @Children1StayAddon3 smallmoney
Declare @Children1DepartureAddon3 smallmoney
Declare @Children2ArrivalAddon3 smallmoney
Declare @Children2StayAddon3 smallmoney
Declare @Children2DepartureAddon3 smallmoney
Declare @AdultArrivalAddon4 smallmoney
Declare @AdultStayAddon4 smallmoney
Declare @AdultDepartureAddon4 smallmoney
Declare @Children1ArrivalAddon4 smallmoney
Declare @Children1StayAddon4 smallmoney
Declare @Children1DepartureAddon4 smallmoney
Declare @Children2ArrivalAddon4 smallmoney
Declare @Children2StayAddon4 smallmoney
Declare @Children2DepartureAddon4 smallmoney
Declare @AdultArrivalAddon5 smallmoney
Declare @AdultStayAddon5 smallmoney
Declare @AdultDepartureAddon5 smallmoney
Declare @Children1ArrivalAddon5 smallmoney
Declare @Children1StayAddon5 smallmoney
Declare @Children1DepartureAddon5 smallmoney
Declare @Children2ArrivalAddon5 smallmoney
Declare @Children2StayAddon5 smallmoney
Declare @Children2DepartureAddon5 smallmoney
Declare @AdultArrivalAddon6 smallmoney
Declare @AdultStayAddon6 smallmoney
Declare @AdultDepartureAddon6 smallmoney
Declare @Children1ArrivalAddon6 smallmoney
Declare @Children1StayAddon6 smallmoney
Declare @Children1DepartureAddon6 smallmoney
Declare @Children2ArrivalAddon6 smallmoney
Declare @Children2StayAddon6 smallmoney
Declare @Children2DepartureAddon6 smallmoney
Declare @AdultArrivalAddon7 smallmoney
Declare @AdultStayAddon7 smallmoney
Declare @AdultDepartureAddon7 smallmoney
Declare @Children1ArrivalAddon7 smallmoney
Declare @Children1StayAddon7 smallmoney
Declare @Children1DepartureAddon7 smallmoney
Declare @Children2ArrivalAddon7 smallmoney
Declare @Children2StayAddon7 smallmoney
Declare @Children2DepartureAddon7 smallmoney
Declare @AdultArrivalAddon8 smallmoney
Declare @AdultStayAddon8 smallmoney
Declare @AdultDepartureAddon8 smallmoney
Declare @Children1ArrivalAddon8 smallmoney
Declare @Children1StayAddon8 smallmoney
Declare @Children1DepartureAddon8 smallmoney
Declare @Children2ArrivalAddon8 smallmoney
Declare @Children2StayAddon8 smallmoney
Declare @Children2DepartureAddon8 smallmoney
Declare @AdultArrivalAddon9 smallmoney
Declare @AdultStayAddon9 smallmoney
Declare @AdultDepartureAddon9 smallmoney
Declare @Children1ArrivalAddon9 smallmoney
Declare @Children1StayAddon9 smallmoney
Declare @Children1DepartureAddon9 smallmoney
Declare @Children2ArrivalAddon9 smallmoney
Declare @Children2StayAddon9 smallmoney
Declare @Children2DepartureAddon9 smallmoney

Declare @ArrivalPacketNumber int
Declare @StayPacketNumber int
Declare @DeparturePacketNumber int

Declare @FormatedSourceDate Char (8)
Declare @CurrentDate Char (8)
Declare @EndDate Char (8)

Select  @FormatedSourceDate = Convert (Char (8), @SourceDate, 112)
Select  @CurrentDate = Convert (Char (8), @DestStartDate, 112)
Select  @EndDate = Convert (Char (8), @DestEndDate, 112)

Declare CopyCur Cursor For
  Select ProductNumber, DateStamp, RoomtypeNumber,
  AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
  Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
  Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
  AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
  AdultArrivalAddon2, AdultStayAddon2, AdultDepartureAddon2, Children1ArrivalAddon2, Children1StayAddon2, Children1DepartureAddon2, Children2ArrivalAddon2, Children2StayAddon2, Children2DepartureAddon2,
  AdultArrivalAddon3, AdultStayAddon3, AdultDepartureAddon3, Children1ArrivalAddon3, Children1StayAddon3, Children1DepartureAddon3, Children2ArrivalAddon3, Children2StayAddon3, Children2DepartureAddon3,
  AdultArrivalAddon4, AdultStayAddon4, AdultDepartureAddon4, Children1ArrivalAddon4, Children1StayAddon4, Children1DepartureAddon4, Children2ArrivalAddon4, Children2StayAddon4, Children2DepartureAddon4,
  AdultArrivalAddon5, AdultStayAddon5, AdultDepartureAddon5, Children1ArrivalAddon5, Children1StayAddon5, Children1DepartureAddon5, Children2ArrivalAddon5, Children2StayAddon5, Children2DepartureAddon5,
  AdultArrivalAddon6, AdultStayAddon6, AdultDepartureAddon6, Children1ArrivalAddon6, Children1StayAddon6, Children1DepartureAddon6, Children2ArrivalAddon6, Children2StayAddon6, Children2DepartureAddon6,
  AdultArrivalAddon7, AdultStayAddon7, AdultDepartureAddon7, Children1ArrivalAddon7, Children1StayAddon7, Children1DepartureAddon7, Children2ArrivalAddon7, Children2StayAddon7, Children2DepartureAddon7,
  AdultArrivalAddon8, AdultStayAddon8, AdultDepartureAddon8, Children1ArrivalAddon8, Children1StayAddon8, Children1DepartureAddon8, Children2ArrivalAddon8, Children2StayAddon8, Children2DepartureAddon8,
  AdultArrivalAddon9, AdultStayAddon9, AdultDepartureAddon9, Children1ArrivalAddon9, Children1StayAddon9, Children1DepartureAddon9, Children2ArrivalAddon9, Children2StayAddon9, Children2DepartureAddon9,
  ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber
 From ProductPrice WITH (NOLOCK)
  Where DateStamp = @FormatedSourceDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber

  Open CopyCur
  Fetch Next From CopyCur
  Into @ProductNumber, @DateStamp, @RoomtypeNumber,
  @AdultPrice1, @AdultPrice2, @AdultPrice3, @AdultPrice4, @AdultPrice5, @AdultPrice6, @AdultPrice7, @AdultPrice8, @AdultPrice9,
  @Children1Price1, @Children1Price2, @Children1Price3, @Children1Price4, @Children1Price5, @Children1Price6, @Children1Price7, @Children1Price8, @Children1Price9,
  @Children2Price1, @Children2Price2, @Children2Price3, @Children2Price4, @Children2Price5, @Children2Price6, @Children2Price7, @Children2Price8, @Children2Price9,
  @AdultArrivalAddon, @AdultStayAddon, @AdultDepartureAddon,@Children1ArrivalAddon,@Children1StayAddon, @Children1DepartureAddon,@Children2ArrivalAddon,@Children2StayAddon, @Children2DepartureAddon,
  @AdultArrivalAddon2, @AdultStayAddon2, @AdultDepartureAddon2, @Children1ArrivalAddon2, @Children1StayAddon2, @Children1DepartureAddon2, @Children2ArrivalAddon2, @Children2StayAddon2, @Children2DepartureAddon2,
  @AdultArrivalAddon3, @AdultStayAddon3, @AdultDepartureAddon3, @Children1ArrivalAddon3, @Children1StayAddon3, @Children1DepartureAddon3, @Children2ArrivalAddon3, @Children2StayAddon3, @Children2DepartureAddon3,
  @AdultArrivalAddon4, @AdultStayAddon4, @AdultDepartureAddon4, @Children1ArrivalAddon4, @Children1StayAddon4, @Children1DepartureAddon4, @Children2ArrivalAddon4, @Children2StayAddon4, @Children2DepartureAddon4,
  @AdultArrivalAddon5, @AdultStayAddon5, @AdultDepartureAddon5, @Children1ArrivalAddon5, @Children1StayAddon5, @Children1DepartureAddon5, @Children2ArrivalAddon5, @Children2StayAddon5, @Children2DepartureAddon5,
  @AdultArrivalAddon6, @AdultStayAddon6, @AdultDepartureAddon6, @Children1ArrivalAddon6, @Children1StayAddon6, @Children1DepartureAddon6, @Children2ArrivalAddon6, @Children2StayAddon6, @Children2DepartureAddon6,
  @AdultArrivalAddon7, @AdultStayAddon7, @AdultDepartureAddon7, @Children1ArrivalAddon7, @Children1StayAddon7, @Children1DepartureAddon7, @Children2ArrivalAddon7, @Children2StayAddon7, @Children2DepartureAddon7,
  @AdultArrivalAddon8, @AdultStayAddon8, @AdultDepartureAddon8, @Children1ArrivalAddon8, @Children1StayAddon8, @Children1DepartureAddon8, @Children2ArrivalAddon8, @Children2StayAddon8, @Children2DepartureAddon8,
  @AdultArrivalAddon9, @AdultStayAddon9, @AdultDepartureAddon9, @Children1ArrivalAddon9, @Children1StayAddon9, @Children1DepartureAddon9, @Children2ArrivalAddon9, @Children2StayAddon9, @Children2DepartureAddon9,
  @ArrivalPacketNumber,@StayPacketNumber, @DeparturePacketNumber

  While @CurrentDate <= @EndDate
  Begin
    IF  @ArrivalPacketNumber = 0 SET @ArrivalPacketNumber = NULL
    IF  @StayPacketNumber = 0 SET @StayPacketNumber = NULL
    IF  @DeparturePacketNumber = 0 SET @DeparturePacketNumber = NULL
    If @CurrentDate <> @FormatedSourceDate -- Do NOT insert on sourcedate
    Begin
        -- Insert with NEW date
      
      if @FieldType = 0
      begin
        if @Persons = 1
        begin
          Update ProductPrice SET
            AdultPrice1 = @AdultPrice1
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultPrice1, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 2
        begin
          Update ProductPrice SET
            AdultPrice2 = @AdultPrice2
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, @AdultPrice2, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 3
        begin
          Update ProductPrice SET
            AdultPrice3 = @AdultPrice3
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, @AdultPrice3, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 4
        begin
          Update ProductPrice SET
            AdultPrice4 = @AdultPrice4
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, @AdultPrice4, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 5
        begin
          Update ProductPrice SET
            AdultPrice5 = @AdultPrice5
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, @AdultPrice5, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 6
        begin
          Update ProductPrice SET
            AdultPrice6 = @AdultPrice6
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, @AdultPrice6, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 7
        begin
          Update ProductPrice SET
            AdultPrice7 = @AdultPrice7
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, @AdultPrice7, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 8
        begin
          Update ProductPrice SET
            AdultPrice8 = @AdultPrice8
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, @AdultPrice8, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 9
        begin
          Update ProductPrice SET
            AdultPrice9 = @AdultPrice9
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,

                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, @AdultPrice9,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
      end

      if @FieldType = 1
      begin
        if @Persons = 1
        begin
          Update ProductPrice SET
            Children1Price1 = @Children1Price1
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     @Children1Price1, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 2
        begin
          Update ProductPrice SET
            Children1Price2 = @Children1Price2
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     @Children1Price2, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 3
        begin
          Update ProductPrice SET
            Children1Price3 = @Children1Price3
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     @Children1Price3, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 4
        begin
          Update ProductPrice SET
            Children1Price4 = @Children1Price4
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     @Children1Price4, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 5
        begin
          Update ProductPrice SET
            Children1Price5 = @Children1Price5
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     @Children1Price5, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 6
        begin
          Update ProductPrice SET
            Children1Price6 = @Children1Price6
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     @Children1Price6, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 7
        begin
          Update ProductPrice SET
            Children1Price7 = @Children1Price7
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, @Children1Price7, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 8
        begin
          Update ProductPrice SET
            Children1Price8 = @Children1Price8
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, @Children1Price8, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 9
        begin
          Update ProductPrice SET
            Children1Price9 = @Children1Price9
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, @Children1Price9,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
      end

      if @FieldType = 2
      begin
        if @Persons = 1
        begin
          Update ProductPrice SET
            Children2Price1 = @Children2Price1
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      @Children2Price1, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 2
        begin
          Update ProductPrice SET
            Children2Price2 = @Children2Price2
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, @Children2Price2, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 3
        begin
          Update ProductPrice SET
            Children2Price3 = @Children2Price3
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber,  0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, @Children2Price3, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 4
        begin
          Update ProductPrice SET
            Children2Price4 = @Children2Price4
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber,  0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, @Children2Price4, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 5
        begin
          Update ProductPrice SET
            Children2Price5 = @Children2Price5
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, @Children2Price5, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 6
        begin
          Update ProductPrice SET
            Children2Price6 = @Children2Price6
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, @Children2Price6, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 7
        begin
          Update ProductPrice SET
            Children2Price7 = @Children2Price7
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, @Children2Price7, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 8
        begin
          Update ProductPrice SET
            Children2Price8 = @Children2Price8
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, @Children2Price8, 0,      0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
        if @Persons = 9
        begin
          Update ProductPrice SET
            Children2Price9 = @Children2Price9
          WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber and RoomTypeNumber = @FieldKeyNumber
          if @@RowCount = 0 -- Nothing was updated -> insert row!
            INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultPrice1, AdultPrice2, AdultPrice3, AdultPrice4, AdultPrice5, AdultPrice6, AdultPrice7, AdultPrice8, AdultPrice9,
                                                          Children1Price1, Children1Price2, Children1Price3, Children1Price4, Children1Price5, Children1Price6, Children1Price7, Children1Price8, Children1Price9,
                                                          Children2Price1, Children2Price2, Children2Price3, Children2Price4, Children2Price5, Children2Price6, Children2Price7, Children2Price8, Children2Price9,
                                                          AdultArrivalAddon, AdultStayAddon, AdultDepartureAddon,Children1ArrivalAddon,Children1StayAddon, Children1DepartureAddon,Children2ArrivalAddon,Children2StayAddon, Children2DepartureAddon,
                                                          ArrivalPacketNumber,StayPacketNumber, DeparturePacketNumber)
            Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0, @Children2Price9,     0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL)
        end
      end

--      if @Persons = 1
      begin
        if @FieldType = 3 -- adult addon
        begin
          if @Persons = 1

          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                AdultArrivalAddon = @AdultArrivalAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon = @AdultStayAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon = @AdultDepartureAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon)
            end
          end
          else if @Persons = 2
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                AdultArrivalAddon2 = @AdultArrivalAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon2)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon2 = @AdultStayAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon2)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon2 = @AdultDepartureAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon2)
            end
          end
          else if @Persons = 3

          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                AdultArrivalAddon3 = @AdultArrivalAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon3) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon3)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon3 = @AdultStayAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon3) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon3)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon3 = @AdultDepartureAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon3)
            end
          end
          else if @Persons = 4
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                AdultArrivalAddon4 = @AdultArrivalAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon4) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon4)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon4 = @AdultStayAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon4) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon4)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon4 = @AdultDepartureAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon4) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon4)
            end
          end
          else if @Persons = 5
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                AdultArrivalAddon5 = @AdultArrivalAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon5) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon5)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon5 = @AdultStayAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon5) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon5)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon5 = @AdultDepartureAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon5) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon5)
            end
          end
          else if @Persons = 6
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                AdultArrivalAddon6 = @AdultArrivalAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon6) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon6)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon6 = @AdultStayAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon6) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon6)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon6 = @AdultDepartureAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon6) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon6)
            end
          end
          else if @Persons = 7
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                AdultArrivalAddon7 = @AdultArrivalAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon7) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon7)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon7 = @AdultStayAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon7) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon7)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon7 = @AdultDepartureAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon7) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon7)
            end
          end
          else if @Persons = 8
          begin
            if @FieldNumber = 0  -- arrival
            begin

              Update ProductPrice SET
                AdultArrivalAddon8 = @AdultArrivalAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon8) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon8)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon8 = @AdultStayAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon8) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon8)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon8 = @AdultDepartureAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon8) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon8)
            end
          end
          else if @Persons = 9
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                AdultArrivalAddon9 = @AdultArrivalAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultArrivalAddon9) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultArrivalAddon9)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                AdultStayAddon9 = @AdultStayAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultStayAddon9) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultStayAddon9)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                AdultDepartureAddon9 = @AdultDepartureAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, AdultDepartureAddon9) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @AdultDepartureAddon9)
            end
          end
        end

        if @FieldType = 4 -- children1 addon
        begin
          if @Persons = 1
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon = @Children1ArrivalAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon)

            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon = @Children1StayAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon = @Children1DepartureAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon)
            end
          end
          else if @Persons = 2
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon2 = @Children1ArrivalAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon2)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon2 = @Children1StayAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon2)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon2 = @Children1DepartureAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon2)
            end
          end
          else if @Persons = 3
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon3 = @Children1ArrivalAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon3) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon3)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon3 = @Children1StayAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon3) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon3)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon3 = @Children1DepartureAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon3) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon3)
            end
          end
          else if @Persons = 4
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon4 = @Children1ArrivalAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon4) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon4)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon4 = @Children1StayAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon4) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon4)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon4 = @Children1DepartureAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon4) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon4)
            end
          end
          else if @Persons = 5
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon5 = @Children1ArrivalAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon5) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon5)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon5 = @Children1StayAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon5) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon5)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon5 = @Children1DepartureAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon5) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon5)
            end
          end
          else if @Persons = 6
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon6 = @Children1ArrivalAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon6) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon6)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon6 = @Children1StayAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon6) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon6)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon6 = @Children1DepartureAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon6) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon6)
            end
          end
          else if @Persons = 7
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon7 = @Children1ArrivalAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon7) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon7)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon7 = @Children1StayAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon7) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon7)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon7 = @Children1DepartureAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon7) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon7)
            end
          end
          else if @Persons = 8
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon8 = @Children1ArrivalAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon8) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon8)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon8 = @Children1StayAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon8) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon8)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon8 = @Children1DepartureAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon8) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon8)
            end
          end
          else if @Persons = 9
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children1ArrivalAddon9 = @Children1ArrivalAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1ArrivalAddon9) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1ArrivalAddon9)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children1StayAddon9 = @Children1StayAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children1StayAddon9) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1StayAddon9)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children1DepartureAddon9 = @Children1DepartureAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice  (ProductNumber, DateStamp, RoomtypeNumber, Children1DepartureAddon9) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children1DepartureAddon9)
            end
          end
        end

        if @FieldType = 5 -- children2 addon
        begin
          if @Persons = 1
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon = @Children2ArrivalAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children2StayAddon = @Children2StayAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon = @Children2DepartureAddon
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon)
            end
          end
          else if @Persons = 2
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon2 = @Children2ArrivalAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon2)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children2StayAddon2 = @Children2StayAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon2) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon2)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon2 = @Children2DepartureAddon2
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon2)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon2)
            end
          end
          else if @Persons = 3
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon3 = @Children2ArrivalAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon3) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon3)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children2StayAddon3 = @Children2StayAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon3) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon3)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon3 = @Children2DepartureAddon3
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon3)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon3)
            end
          end
          else if @Persons = 4
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon4 = @Children2ArrivalAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon4) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon4)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children2StayAddon4 = @Children2StayAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon4) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon4)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon4 = @Children2DepartureAddon4
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon4)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon4)
            end
          end
          else if @Persons = 5
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon5 = @Children2ArrivalAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon5) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon5)
            end
            else if @FieldNumber = 1  -- stay



            begin
              Update ProductPrice SET
                Children2StayAddon5 = @Children2StayAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon5) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon5)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon5 = @Children2DepartureAddon5
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon5)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon5)
            end
          end
          else if @Persons = 6
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon6 = @Children2ArrivalAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon6) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon6)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children2StayAddon6 = @Children2StayAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon6) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon6)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon6 = @Children2DepartureAddon6
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon6)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon6)
            end
          end
          else if @Persons = 7
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon7 = @Children2ArrivalAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon7) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon7)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children2StayAddon7 = @Children2StayAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon7) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon7)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon7 = @Children2DepartureAddon7
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon7)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon7)
            end
          end
          else if @Persons = 8
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon8 = @Children2ArrivalAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon8) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon8)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children2StayAddon8 = @Children2StayAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon8) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon8)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon8 = @Children2DepartureAddon8
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon8)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon8)
            end
          end
          else if @Persons = 9
          begin
            if @FieldNumber = 0  -- arrival
            begin
              Update ProductPrice SET
                Children2ArrivalAddon9 = @Children2ArrivalAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2ArrivalAddon9) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2ArrivalAddon9)
            end
            else if @FieldNumber = 1  -- stay
            begin
              Update ProductPrice SET
                Children2StayAddon9 = @Children2StayAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!
                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2StayAddon9) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2StayAddon9)
            end
            else if @FieldNumber = 2 -- departure
            begin
              Update ProductPrice SET
                Children2DepartureAddon9 = @Children2DepartureAddon9
              WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
              if @@RowCount = 0 -- Nothing was updated -> insert row!



                INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, Children2DepartureAddon9)  Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @Children2DepartureAddon9)
            end
          end
        end

        if @FieldType = 6 and @Persons = 1 -- packet
        begin
          if @FieldNumber = 0  -- arrival
          begin
            Update ProductPrice SET
              ArrivalPacketNumber = @ArrivalPacketNumber
            WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
            if @@RowCount = 0 -- Nothing was updated -> insert row!
              INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, ArrivalPacketNumber) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @ArrivalPacketNumber)
          end
          else if @FieldNumber = 1  -- stay
          begin
            Update ProductPrice SET
             StayPacketNumber = @StayPacketNumber
            WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
            if @@RowCount = 0 -- Nothing was updated -> insert row!
              INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, StayPacketNumber) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @StayPacketNumber)
          end
          else if @FieldNumber = 2 -- departure
          begin
            Update ProductPrice SET
              DeparturePacketNumber = @DeparturePacketNumber
            WHERE DateStamp=@CurrentDate and ProductNumber = @OldProductNumber --and RoomTypeNumber = @FieldKeyNumber
            if @@RowCount = 0 -- Nothing was updated -> insert row!
              INSERT INTO ProductPrice (ProductNumber, DateStamp, RoomtypeNumber, DeparturePacketNumber) Values (@OldProductNumber, @CurrentDate, @RoomtypeNumber, @DeparturePacketNumber)
          end
        end
      end

    End
      Set @DestStartDate = @DestStartDate +1
      Select  @CurrentDate =  Convert (Char (10), @DestStartDate, 112)
End

--Deallocate Cursor
Deallocate CopyCur

