-
Richard Donagrandi
- PowerBuilder
- Friday, 1 August 2025 06:28 PM UTC
PB 22.2.0.3397
SQL Server 2022/ODBC driver v18
I've found that Powerbuilder is inconsistent with passing parameter values in inline SQL to SQL Server. -- Possibly because of the use of CASE statements elsewhere in the inline SQL.
Something like:
Can generate "The data types char and char are incompatible in the subtract operator." (Nothing is defined as a char, all values are long.)
Something as simple as
SET in_avg_cost = :ldec_avgcost
Can generate "Conversion failed when converting the varchar value '7.99 ' to data type int" or "Arithmetic overflow error converting varchar to data type numeric."
-- even though the field in_avg_cost is a decimal in the database, and ldec_avgcost is also a decimal.
When a string value is included within a CASE statement, I've had: "Cannot convert to text/ntext or collate to 'Latin1_General_100_CI_AI_SC_UTF8' because these legacy LOB types do not support UTF-8 or UTF-16 encodings. Use types varchar(max), nvarchar(max) or a collation which does not have the _SC or _UTF8 flags."
-- We use inline SQL all over the place, and 90% of the time, we never have any problem. Then, occasionally, this happens. It's very inconsistent, but it does seem to happen more often within CASE statements or SQL that uses CASE statements. Even inline SQL within the same function may work just fine without error using the same passed variables and values.
WORKAROUNDS:
Convert the inline sql to a datawindow, or encapsulate passing values within CONVERT/CAST statements.
CONVERT(varchar, :ls_value)
CONVERT(decimal(30,3), :ldec_avgcost)
CONVERT(integer, :ll_QtyRx)
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.