1. Larry Pettit
  2. PowerBuilder
  3. 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?
 
 


Responses (2)
  1. Likes
  2. Latest
  3. Oldest
Loading...

Find Questions by Tag

.EXE .NET 6.0 .NET Assembly .NET Core 3.1 .NET Core Framework .NET DataStore .NET Std Framework 32-bit 64-bit ADO.NET AEM AI Algorithm Amazon AWS Android Apache API APK App Store App Store (Apple) Appeon Workspace Appeon Xcelerator Plug-in Architecture Array ASE Asynchronous Methods Authentication AutoBuild AutoCompiler Automated Testing Automation AutoScript Azure Barcode Base64 Batch BigData BLOB Branch & Merge Browser Bug Build Button C# C# Class Importer C# Editor C# Model generator Calendar Camera Certificate Chrome Citrix Class Client Client/Server Cloud Cluster Collection COM Command Line Compiler Compression Computed Field Configuration Controls Cookies Cordova Crash Cross-Platform Crosstab CSharpAssembly CSharpObject CSS CSV Cursor Data Database Database Driver Database Painter Database Profile Database Provider DataObject DataSource DataStore DataStore (C#) DataStore (PS) DataType DataWindow DATE DATETIME DB2 Debug Debugger Debugging Deployment Design DLL DO-WHILE Dockable Docker Documentation DOUBLE Download DPI DragDrop Edge Edit Style Editor Elevate Conference Email Embedded SQL Emulator Encoding Encryption Enhancement Request Entity Entity Framework ERP Error Event Event Handler Event Handling Excel Exception Export Expression External Functions F# Field File File Access Filter Firefox Firewall Font FOR-NEXT Foreground Format Function Garbage Collection GeoLocation Git Graph HANA Hash Header HTML/5 HTTP/S HTTPClient Icon IDE Identity IIS IMAPI Import InfoMaker Inheritance Installation Integer IntelliSense Interface Internet Internet Explorer iOS IPA iPad iPhone IWA J# Java JavaScript JBoss JDBC JOIN JSON JSONGenerator JSONParser Kestrel Label Lambda Large File LDAP Library License LINQ Linux OS Load Balancing Localization Localized PBVM Log In Log Out Logging LONG LONGLONG macOS MAPI Maps MDI Memory Memory Leak Menu Merge MessageBox Messagging Method Migration MIME TYPE Mobile Model ModelStore ModelStore (C#) MSOLEDBSQL Multi Threading MVC MySQL n-Tier Namespace NativePDF Nube NVO OAuth ODATA ODBC Office Offline OLE OLEDB Online Open Source OpenAPI OpenSSL Oracle OrcaScript Other Outlook Output Package Parameter Patch PayPal PB Classic PB Native PB.NET PBC PBD PBDOM PBG PBJVM PBL PBNI PBORCA PBVM PBX PDF Performance Permission PFC Picture Pipeline Play Store (Google) Plugin Popup Port POST PostgreSQL PowerBuilder PowerBuilder (Appeon) PowerBuilder (SAP) PowerBuilder Compiler PowerBuilder Runtime PowerClient PowerScript (PS) PowerScript IDE PowerScript Migrator PowerServer PowerServer Mobile PowerServer Toolkit PowerServer Web PowerServerLabel Print Properties Proxy Publish PULL PUSH Query Regression Release Renew Resize Response REST Retrieve RibbonBar RibbonBar Builder RibbonView Rich Text Roadmap RPC Runtime Packager SaaS Scaffolding Script SDI SDK Security Server Service Session Single Sign-on Size SMTP SMTPClient SnapDevelop SOAP Solution Sort Source Code Speech Recognition SQL SQL Anywhere SQL Server SqlBuilder SqlExecutor SQLite SqlModelMapper Storage Stored Procedure Subscription SVN Swagger Syntax TabbedBar TabbedView Tablet TabPage Target TE Control Testing Text TFS Theme TIME Timer TLS/SSL Tomcat TortoiseGit TortoiseSVN Transaction Transparency Trial Trigger TRY-CATCH TX Control Type UI ULONG UltraLite Uninstall Unit Test Unit Testing UNIX OS Update Upgrade Upload URL User Center User Object UWP Validation VARCHAR Variable Versioning Visual Studio Visual Studio Code VM Voice Warning WCF Web API Web Extensions Web Service WebBrowser WebForms WebLogic WebSphere WildFly WinAPI Window Windows OS WinForms Wizard Workgroup Workspace WPF XCODE XHTML XML Zoom
✖

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.