-
Larry Pettit
- PowerBuilder
- Wednesday, 25 November 2026 07:49 PM UTC
Subject: MSOLEDBSQL SQL Server interface binds decimal host variables as nvarchar (DisableBind=0), so embedded SQL arithmetic and comparisons fail or return wrong results
Environment
PowerBuilder 2025 R2, runtime 25.1.0.6464, 64-bit executable
DBMS = MSOLEDBSQL SQL Server, provider MSOLEDBSQL19 (Microsoft OLE DB Driver 19 for SQL Server)
SQL Server 2025 (17.0.5045.3)
DBParm:
Provider='MSOLEDBSQL19',TrustedConnection=1,CommitOnDisconnect='No',DisableBind=0,NCharBind=1,StaticBind=1,DelimitIdentifier=1,TrustServerCertificate=1,Encrypt=1,ProviderString='database=<db>'
Problem
With DisableBind=0, embedded SQL sends PowerScript decimal host variables to SQL Server as nvarchar parameters. We confirmed this with sql_variant_property(:var, 'BaseType'):
PowerScript type
Type SQL Server receives
decimal, decimal{2}
nvarchar
double
float
integer
smallint
long
int
string
nvarchar
datetime
datetimeoffset (+00:00)
The result is the same with NCharBind=0 and with StaticBind=0. Only DisableBind=1 changes it.
Reproduction (any table with one row; ld_a = 1450.25, ld_b = 50.25)
select :ld_a - :ld_b into :ld_r from some_table; // error: nvarchar and nvarchar are incompatible in the subtract operator
select :ld_a + :ld_b into :ls_r from some_table; // no error, returns '1450.2550.25' (string concatenation)
select :ld_a * :ld_b into :ld_r from some_table; // error: operand data type nvarchar is invalid for multiply
select :ld_a * (-1) into :ld_r from some_table; // error: conversion of nvarchar '1450.25' to int failed
select :ld_a + 1 into :ld_r from some_table; // same conversion error
select count(*) into :ll_r from some_table where :ld_a > 0; // same conversion error
// with ld_a = 9.50, ld_b = 10.25:
select count(*) into :ll_r from some_table where :ld_a > :ld_b; // returns 1: compared as text, wrong with no error
The integer-literal cases work only when the decimal holds a whole number (1978 * -1 works, 1978.84 * -1 fails), so the failures show up depending on the data.
The same statements return correct results with DisableBind=1.
Datetime
datetime host variables are bound as datetimeoffset at +00:00:
insert ... values (:ldt) and where col = :ldt store and compare correctly.
select dateadd(day, 1, :ldt) into :ldt_out returns the time shifted by the client's UTC offset. A 13:45:30 input came back as 07:45:30 on a US Central machine.
select :ldt + 1 ... fails with "Operand type clash: datetime2 is incompatible with int".
Why DisableBind=1 isn't a workaround
With DisableBind=1, Unicode strings in host variables are corrupted. select :ls_in into :ls_out with ls_in = "Peña Café 日本" returns a different string. With DisableBind=0, the round trip is exact.
Expected behavior
Decimal host variables are bound as a numeric type (DBTYPE_NUMERIC or DBTYPE_DECIMAL) with appropriate precision and scale, and datetime host variables as datetime2 or DBTIMESTAMP without a time-zone offset. Arithmetic and comparisons should then behave the same with DisableBind=0 as with DisableBind=1.
Questions
Is binding decimals as nvarchar and datetimes as datetimeoffset intended for the MSOLEDBSQL SQL Server interface?
Is there a DBParm setting that binds decimals numerically and datetimes without an offset, while keeping DisableBind=0 for correct Unicode?
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.