0

I am so stumped on this, thought I would post for a 2nd set of eyes. I would love some help.

One of my ETL scripts started failing on certain tables with the error on Insert: [1136] Column count doesn't match value count at row 1

I isolated the insert query to just one row and still get the error. Obviously, the first thing I checked was that was the same number of columns and values, they seem to match.

What could I be missing? Since the error just randomly started that makes me think it's either a data issue or perhaps a change in schema on the source DB but I am stumped:

Here is the failing insert query:

INSERT INTO recurringgifts
(Id, LegacyId, TransactionSource, TransactionId, ContactId, RecurringGiftDate, ExpectedFulfillmentDate, Amount,
 Frequency, SegmentId, ProjectDesignationId, ImportId, TrackPaymentsDateTimeUtc, AutomatedPayments, IsPrivate,
 FulfillmentDateTimeUtc, ThankYouDateTimeUtc, CancelDateTimeUtc, LastPaymentDate, LastExpectedPaymentDate,
 NextExpectedPaymentDate, Status, Culture, ExchangeRate, CreatedByUserId, LastModifiedByUserId, OrganizationId,
 IsDeleted, CreatedDateTimeUtc, ModifiedDateTimeUtc, Balance, DesignationsLastUpdated, CancellationCategoryId,
 CancellationReason, CoversCost, Costs)
VALUES (18, 'W-1264060', null, null, 177741, '2014-09-29 00:00:00.000', null, 30.00, 3, 1,
        null, 33, '2022-03-03 15:25:02.953', 1, 0, null, null, '2019-01-01 00:00:00.000', '2019-01-01 00:00:00.000',
        null, '2014-09-29 00:00:00.000', 2, 'en-US', 1.000000000, null, null, 2794, 0, '2022-03-03 15:25:02.953',
        '2022-06-14 11:17:16.310', 0.00, null, null, null, 0, 0.00)
ON DUPLICATE KEY UPDATE Id=VALUES(Id),
                        LegacyId=VALUES(LegacyId),
                        TransactionSource=VALUES(TransactionSource),
                        TransactionId=VALUES(TransactionId),
                        ContactId=VALUES(ContactId),
                        RecurringGiftDate=VALUES(RecurringGiftDate),
                        ExpectedFulfillmentDate=VALUES(ExpectedFulfillmentDate),
                        Amount=VALUES(Amount),
                        Frequency=VALUES(Frequency),
                        SegmentId=VALUES(SegmentId),
                        ProjectDesignationId=VALUES(ProjectDesignationId),
                        ImportId=VALUES(ImportId),
                        TrackPaymentsDateTimeUtc=VALUES(TrackPaymentsDateTimeUtc),
                        AutomatedPayments=VALUES(AutomatedPayments),
                        IsPrivate=VALUES(IsPrivate),
                        FulfillmentDateTimeUtc=VALUES(FulfillmentDateTimeUtc),
                        ThankYouDateTimeUtc=VALUES(ThankYouDateTimeUtc),
                        CancelDateTimeUtc=VALUES(CancelDateTimeUtc),
                        LastPaymentDate=VALUES(LastPaymentDate),
                        LastExpectedPaymentDate=VALUES(LastExpectedPaymentDate),
                        NextExpectedPaymentDate=VALUES(NextExpectedPaymentDate),
                        Status=VALUES(Status),
                        Culture=VALUES(Culture),
                        ExchangeRate=VALUES(ExchangeRate),
                        CreatedByUserId=VALUES(CreatedByUserId),
                        LastModifiedByUserId=VALUES(LastModifiedByUserId),
                        OrganizationId=VALUES(OrganizationId),
                        IsDeleted=VALUES(IsDeleted),
                        CreatedDateTimeUtc=VALUES(CreatedDateTimeUtc),
                        ModifiedDateTimeUtc=VALUES(ModifiedDateTimeUtc),
                        Balance=VALUES(Balance),
                        DesignationsLastUpdated=VALUES(DesignationsLastUpdated),
                        CancellationCategoryId=VALUES(CancellationCategoryId),
                        CancellationReason=VALUES(CancellationReason),
                        CoversCost=VALUES(CoversCost),
                        Costs=VALUES(Costs)

Here is the DDL for that table:

create table recurringgifts
(
    Id                       int            not null
        primary key,
    LegacyId                 varchar(2048)  null,
    TransactionSource        varchar(2048)  null,
    TransactionId            varchar(2048)  null,
    ContactId                int            not null,
    RecurringGiftDate        datetime       not null,
    ExpectedFulfillmentDate  datetime       null,
    Amount                   decimal(18, 2) not null,
    Frequency                int            not null,
    SegmentId                int            null,
    ProjectDesignationId     int            null,
    ImportId                 int            null,
    TrackPaymentsDateTimeUtc datetime       null,
    AutomatedPayments        tinyint(1)     not null,
    IsPrivate                tinyint(1)     not null,
    FulfillmentDateTimeUtc   datetime       null,
    ThankYouDateTimeUtc      datetime       null,
    CancelDateTimeUtc        datetime       null,
    LastPaymentDate          datetime       null,
    LastExpectedPaymentDate  datetime       null,
    NextExpectedPaymentDate  datetime       null,
    Status                   int            not null,
    Culture                  varchar(10)    null,
    ExchangeRate             decimal(19, 9) not null,
    CreatedByUserId          int            null,
    LastModifiedByUserId     int            null,
    OrganizationId           int            not null,
    IsDeleted                tinyint(1)     not null,
    CreatedDateTimeUtc       datetime       not null,
    ModifiedDateTimeUtc      datetime       not null,
    Balance                  decimal(18, 2) not null,
    DesignationsLastUpdated  datetime       null,
    CancellationCategoryId   int            null,
    CancellationReason       varchar(2048)  null,
    CoversCost               tinyint(1)     not null,
    Costs                    decimal(18, 2) not null
);
Steven Carlton
  • 422
  • 4
  • 23
  • 1
    Is the tag correct? It says Postgres but this looks more like MySQL dialect. – nofinator Jun 14 '22 at 20:07
  • 1
    Do you have a trigger on this table? See https://stackoverflow.com/q/5054623/245915 – nofinator Jun 14 '22 at 20:13
  • @nofinator sheesh. You are right. Our main warehouse is Postgres but realized this db I am populating is MySQL. Thanks, updated! – Steven Carlton Jun 14 '22 at 20:31
  • @nofinator that trigger theory seems right. I am seeing triggers that were probably added by another DB admin and would explain why it randomly stopped working on some tables. Thank you! – Steven Carlton Jun 14 '22 at 20:40

0 Answers0