I have an update job that matches new values in a remote database, and I am having difficulties with getting the updates written back to the original table.
Table 1 has two fields that I am concerned with
DCN (Not Unique)
PolicyNumber (Not Unique)
I am getting a feed (Comma delimited file) from a remote platform containing the DCN and updated PolicyNumber:
DCN, POLICYNUMBER
'ABCDEFGH','1234567890'
I load these values into Table 2. These values represent more than one table, so there will be DCN's in the file that aren't located on TABLE1.
The problem comes from the attempted update. I have tried two methods; an inner join update, and a subselect update.
The INNER JOIN Update is written as
UPDATE TABLE1 INNER JOIN TABLE2 ON TABLE1.DCN = TABLE2.DCN SET TABLE1.POLICYNUMBER = TABLE2.POLICYNUMBER
This query fails due to syntax.
The subselect query is written as
UPDATE TABLE1 SET DCN = (SELECT TABLE2.POLICYNUMBER WHERE TABLE1.DCN=TABLE2.DCN)
This also fails with the following error:
DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=28, COLNO=1" is not allowed. SQLSTATE=23502
One thing I did try was to use MS ACCESS w/ ODBC to DB2, and the inner join works on that platform. However, this needs to be scheduled job in DB2, so this approach is not desireable.
I also looked into an INSERT-UPDATE import possiblity, but this hasn't gotten very far.
Any help would be appreciated.
Thanks
Curtis
Table 1 has two fields that I am concerned with
DCN (Not Unique)
PolicyNumber (Not Unique)
I am getting a feed (Comma delimited file) from a remote platform containing the DCN and updated PolicyNumber:
DCN, POLICYNUMBER
'ABCDEFGH','1234567890'
I load these values into Table 2. These values represent more than one table, so there will be DCN's in the file that aren't located on TABLE1.
The problem comes from the attempted update. I have tried two methods; an inner join update, and a subselect update.
The INNER JOIN Update is written as
UPDATE TABLE1 INNER JOIN TABLE2 ON TABLE1.DCN = TABLE2.DCN SET TABLE1.POLICYNUMBER = TABLE2.POLICYNUMBER
This query fails due to syntax.
The subselect query is written as
UPDATE TABLE1 SET DCN = (SELECT TABLE2.POLICYNUMBER WHERE TABLE1.DCN=TABLE2.DCN)
This also fails with the following error:
DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=28, COLNO=1" is not allowed. SQLSTATE=23502
One thing I did try was to use MS ACCESS w/ ODBC to DB2, and the inner join works on that platform. However, this needs to be scheduled job in DB2, so this approach is not desireable.
I also looked into an INSERT-UPDATE import possiblity, but this hasn't gotten very far.
Any help would be appreciated.
Thanks
Curtis