0

誰かが以下を手伝ってくれませんか - 私は先週これを投稿しました。コードを実行しましたが、誰かがコードを削除しました。誰か助けてくれませんか?

私が得ているエラーは -

メッセージ 16924、レベル 16、状態 1、行 43 Cursorfetch: INTO リストで宣言された変数の数は、選択した列の数と一致する必要があります。

  -- declare cursor variables
  declare @PKCustomerRecord int, @Agent varchar(100), @CallBackDateTime datetime
  declare @Title varchar(15), @Forename varchar(30), @Surname varchar(30), 
          @Address1 varchar(50), @Address2 varchar(50), @Address3 varchar(50), @Address4 varchar(50), @Address5 varchar(50), 
          @PostCode varchar(10), @ContactNumber varchar(16), @Telephone2 varchar(16), 
          @DOB datetime, @Source varchar(30), @list_id int, @user_group varchar(8), @campaign_id varchar(8), @ViciDialID int, 
          @PKUsers int, @LeadId int, @ViciUser varchar(20), @Comments varchar(max)


  -- declare cursor
 declare csr cursor for 
  select 
        ViciDialID, PKUsers, CallBackDateTime, CallBackDateTime, [user] as Agent,
        ci.PKCustomerRecord, ci.Title, ci.Forename, ci.Surname,
        ci.Address1, ci.Address2, ci.Address3, ci.Address4, ci.Address5, ci.PostCode,
        ci.DOB, case when ci.Source = 'CB' then ci.ContactLoadSource else ci.Source end as Source,
        cb.ContactNumber,
        case when cb.ContactNumber COLLATE DATABASE_DEFAULT <> ci.Telephone1 then ci.Telephone1 
        when cb.ContactNumber COLLATE DATABASE_DEFAULT <> Telephone2 then Telephone2 end as Telephone2,
        case 
        when ci.Source = 'SASurvey' then 8890 
        when ci.Source = 'AAR' then 8891
        when ci.Source = 'CB' then 8893
        when ci.Source = 'RTA' then 8894
        when ci.Source = 'Verve Survey' then 8895
        when ci.Source = 'Unregistered' then 8892 end as list_id, user_group, campaign_id,
        cb.Comments
  from CAGSQL.CallCenter.dbo.CallBacks cb with (nolock)
  join #ViciDialData u with (nolock) on cb.UserFK = u.PKUsers
  join CAGSQL.ConsumerCare.dbo.ContactInfo ci with (nolock) on cb.ContactInfoFK = ci.PKCustomerRecord  
  where PoolFK = '173'
  and CallBackDateTime >= getdate()  
  and CallBackDateTime <= convert(varchar,getdate()+1,112)  
  and UpdatedDate is null 
  and Source in ('SASurvey','AAR','CB','RTA','Verve Survey','Unregistered')
  and DataLength(Comments) < 255
  and UpdatedDate is null 
  and PKUsers <> 4678


  open csr
  -- fetch first record
  fetch next from csr into @PKCustomerRecord, @Agent, @CallBackDateTime, @Title, @Forename, @Surname, 
        @Address1, @Address2, @Address3, @Address4, @Address5, @PostCode, @ContactNumber, @Telephone2, @DOB, @Source, @list_id, @user_group, @campaign_id,
        @ViciDialID, @Comments

  while @@fetch_status = 0
  begin 



        if left(@ContactNumber, 1) = '0' set @ContactNumber = substring(@ContactNumber,2,11)
        if left(@Telephone2, 1) = '0' set @Telephone2 = substring(@Telephone2,2,11)

        insert into VICI...vicidial_list
        (status, entry_date, status, [user],  list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, alt_phone, title, 
        first_name, last_name, address1, address2, address3, city, postal_code, date_of_birth, entry_list_id, source_id)
        values
        ('NEW', getdate(), 'CBHOLD', '', @list_id, 1, 'N', '44', @ContactNumber, @Telephone2, @Title, 
        @Forename, @Surname, @Address1, @Address2, @Address3, @address4, @PostCode, @DOB, @list_id, @Source)

        -- get the ID of the record just inserted
        select @LeadId = max(lead_id) from VICI...vicidial_list

        -- insert the callback record into Vici dial
        insert into VICI...vicidial_callbacks
        (lead_id, list_id, campaign_id, status, entry_time, callback_time, modify_date, [user], recipient, 
        comments, user_group, lead_status)
        values 
        (@LeadId, @list_id, 'CCWarm', 'ACTIVE', getdate(), @CallBackDateTime, getdate(), @ViciUser, 'USERONLY', 
        @Comments, 'CCWarm', 'CALLBK')


        -- fetch next record from CURSOR
        fetch next from csr into @PKCustomerRecord, @Agent, @CallBackDateTime, @Title, @Forename, @Surname, 
        @Address1, @Address2, @Address3, @Address4, @Address5, @PostCode, @ContactNumber, @Telephone2, @DOB, @Source, @list_id, @user_group, @campaign_id,
        @ViciDialID, @PKUsers, @Comments

  end -- END OF CURSOR LOOP

  close csr
  deallocate csr

前もってありがとう、ネイサン

4

1 に答える 1