I have a "simple" update I'm trying to do. The idea is to update a field in table A with the value in table B, where the two tables can be joined on a common field. Here is a sample from among many variations on the theme.
update pub.citationmaster A
set (a.cstatus) = (SELECT COALESCE(B.statuscode, A.cstatus) FROM pub.mtistatus B
where B.ticketno = A.ccitationno)
This gives
=== SQL Exception 1 ===
SQLState=42000
ErrorCode=-20003
[JDBC Progress Driver]:Syntax error (7587)
I've been told by Progress Support that this is a bug in the SQL-92 interpreter, and that they will investigate, and either publish a fix or change the documentation (which suggests that this kind up update should work). This is a very common SQL statement structure and works in other databases (e.g. MS SQL Server).
The above statement would (if it worked) update ALL records in table A. To update only those records where there is a corresponding record in table B, the following should work (and does in other databases):
UPDATE pub.CitationMaster
SET
(cStatus) = (SELECT b.StatusCode FROM pub.MTIStatus as b
WHERE cCitationNo = b.TicketNo)
WHERE EXISTS (SELECT * FROM pub.MTIStatus as b2
WHERE cCitationNo = b2.TicketNo)
However, this results in
=== SQL Exception 1 ===
SQLState=HY000
ErrorCode=-20009
[JDBC Progress Driver]:Column ambiguously specified (7523)
Does anybody know of a way to make this kind of correlated update actually work? I'm using 9.1D.
update pub.citationmaster A
set (a.cstatus) = (SELECT COALESCE(B.statuscode, A.cstatus) FROM pub.mtistatus B
where B.ticketno = A.ccitationno)
This gives
=== SQL Exception 1 ===
SQLState=42000
ErrorCode=-20003
[JDBC Progress Driver]:Syntax error (7587)
I've been told by Progress Support that this is a bug in the SQL-92 interpreter, and that they will investigate, and either publish a fix or change the documentation (which suggests that this kind up update should work). This is a very common SQL statement structure and works in other databases (e.g. MS SQL Server).
The above statement would (if it worked) update ALL records in table A. To update only those records where there is a corresponding record in table B, the following should work (and does in other databases):
UPDATE pub.CitationMaster
SET
(cStatus) = (SELECT b.StatusCode FROM pub.MTIStatus as b
WHERE cCitationNo = b.TicketNo)
WHERE EXISTS (SELECT * FROM pub.MTIStatus as b2
WHERE cCitationNo = b2.TicketNo)
However, this results in
=== SQL Exception 1 ===
SQLState=HY000
ErrorCode=-20009
[JDBC Progress Driver]:Column ambiguously specified (7523)
Does anybody know of a way to make this kind of correlated update actually work? I'm using 9.1D.