问题
I get this error from Progress database when running the following query using ODBC:
SELECT distinct Table.column,
{ fn CONVERT(SUBSTRING(Table.ProblematicColumn, 1, 60), SQL_VARCHAR)} as test
FROM PUB.Table
WHERE ( Table.id IN (
SELECT Table.id
FROM PUB.Table
) )
I know it's possible to fix it using the DBTools. However, I run queries against multiple Progress databases of multiple clients, so it's not practical to do this every time. Also, for some reason, the ODBC client I'm using (PHP), doesn't show any error when this happens. Instead, it returns an empty result.
The convert I did to a VAR_CHAR of 60 character did help until I added the sub-query. When the sub-query is there, I get again the same error.
Interestingly enough, when the 'distinct' is not there, it's working. But I do need the distinct.
Edit: The question is how can I execute this query without fixing the width column with DBTool.
回答1:
It took a few minutes to find an answer. The problem appears to be in the OE10 SQL broker not handling the sub select in the where clause. This alternative using an inner join to a sub select looks to be equivalent to me. I tested it, it does work. Replacing the SQL client will do nothing, the error occurs in the OpenEdge SQL broker: I get the same error using the OpenEdge JDBC driver.
SELECT distinct Table.column,
{ fn CONVERT(SUBSTRING(Table.ProblematicColumn, 1, 60), SQL_VARCHAR)} as test
FROM PUB.Table inner join (select id from PUB.Table) t2 on Table.id = t2.id
回答2:
Upgrade to OE 11.6.
There are options in 11.6 to automatically and silently truncate the data so that you will not get an error.
"Autonomous Schema Update"
https://community.progress.com/community_groups/openedge_rdbms/f/18/t/19534
来源:https://stackoverflow.com/questions/38086782/odbc-error-column-x-in-table-y-has-value-exceeding-its-max-length-or-precision