I am using an ODBC driver to connect to a Progress database via a Windows C# application. The problem I am having is my data is being truncated.
SELECT
CASE
WHEN (table1_qty_comp = 0) THEN 'Pending'
ELSE
CASE WHEN (table1_qty_comp >= table2_qty_req) THEN 'Completed'
ELSE 'In-Process'
END
END AS 'Status'
FROM
table1 LEFT JOIN table2 ON table1_part = table2_part
Only 8 characters will appear in my 'Status' column so 'In-Process' turns into 'In-Proce'.
I've tried various casts/converts such as
cast('In-Process' as varchar)
cast('In-Process' as varchar(12))
cast('In-Process' as nvarchar)
cast('In-Process' as nvarchar(12))
convert(varchar(12), 'In-Process')
convert(nvarchar(12), 'In-Process')
str('In-Process')
to no avail. How can I get the full 'In-Process' to appear in my column?
Here is how I query the Progress database from C#
DataTable dt = new DataTable();
try
{
using (OdbcConnection conn = new OdbcConnection(GetConnectionString(db)))
{
OdbcCommand cmd = new OdbcCommand(qry, conn);
conn.Open();
OdbcDataAdapter adpt = new OdbcDataAdapter(cmd);
adpt.Fill(dt);
}
}
catch (OdbcException e)
{
}
return dt;
Update
I wanted to append my question with what may be useful information... This is ODBC driver: Vendor=DataDirect, Progress SQL92 v9.1E, version 4.10.01. Here are some resources for this particular driver provided by another user in the comments, here and here Also, I was able to solve my issue by not using nested CASE
statements like:
SELECT
CASE
WHEN (table1_qty_comp = 0) THEN 'Pending'
WHEN (table1_qty_comp >= table2_qty_req) THEN 'Completed'
ELSE 'In-Process'
END AS 'Status'
FROM
table1 LEFT JOIN table2 ON table1_part = table2_part
The Progress database stores all values as variable length and does not honor any width attribute.
The Progress 4GL is perfectly happy dealing with "over stuffed" fields. This is normal for a Progress application but it gives fits to SQL clients.
You are running Progress version 9 (which is ancient, obsolete and unsupported) so your only options are to either deal with it on the client (as seen in the post and the answer by T.S.) or to run the provided "dbtool" utility. The dbtool utility will scan the database and find any fields that have been over stuffed and then adjust the "sql width" so that SQL clients have an accurate picture of the actual data width.
This might be helpful:
Fixing sql length error in progress 4gl 10.2B
(that answer is for OpenEdge 10.2b but it will work just as well with Progress 9.1e)