-
Bill Gates
- PowerBuilder
- Monday, 20 April 2026 05:53 PM UTC
Environment: PowerBuilder 2022 R3 (Build 22.2.0.3441), SQL Server, MSOLEDBSQL driver
Summary:
The DataWindow SQL parser scans the entire SQL text — including -- line comments — for :identifier patterns and interprets them as retrieval argument binding points. This causes parameter mapping corruption and silently returns zero rows with no error message.
Steps to Reproduce:
1. Create a DataWindow with a simple query that uses retrieval arguments, e.g. :t1 and :t2.
2. Add -- comments at the top of the SQL that mention the parameter names with the colon prefix:
-- Parameters:
-- :t1 DATETIME - start date
-- :t2 DATETIME - end date
SELECT id, name
FROM my_table
WHERE created_date BETWEEN :t1 AND :t2
3.Retrieve the DataWindow with valid arguments. Result: 0 rows returned, even though the same query without comments returns the expected data.
4.Now remove the colon prefix from the comments:
-- Parameters:
-- t1 DATETIME - start date
-- t2 DATETIME - end date
SELECT id, name
FROM my_table
WHERE created_date BETWEEN :t1 AND :t2
5.Retrieve again. Result: correct rows returned.
Root Cause Analysis:
The DataWindow parameter parser performs a full-text scan for :identifier patterns to build the retrieval argument list. It does not skip -- comment blocks during this scan. When :t1 appears both in a comment and in the actual WHERE clause, PB registers duplicate parameter binding points, causing argument positions to shift. The WHERE clause then receives incorrect (or empty) values, resulting in zero rows.
Impact:
This is a silent data loss scenario — no error is raised, no warning is shown. The DataWindow simply returns an empty result set. This can be extremely difficult to diagnose, especially when adding documentation comments to complex SQL queries.
Workaround:
Never use :identifier patterns (colon followed by a word) inside SQL comments in a DataWindow. If you need to document parameter names in comments, omit the colon prefix:
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.