- Suhas Shravagi
- PowerBuilder
- Tuesday, 25 January 2022 04:12 PM UTC
Hi
I have a desktop application developed in PB2017 R3. It is connecting to the MS SQL database thru ODBC with connection string as below:
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = True
SQLCA.DBParm = "ConnectString='DSN=dsn_name;UID=xyz;PWD=abc',CommitOnDisconnect='No',TrimSpaces='Yes'"
With this connection string, the connection to the database is happening successfully as SQLCA.SqlCode is 0. However, it is failing to execute one query in the application. The query looks like somewhat as below:
SELECT IsNull(col1,'') INTO :ls_pwd
FROM tab_name
WHERE Upper(col2) = Upper(:struct.id)
USING SQLCA;
Here struct.id is a field from struct structure and its datatype is String. The column col2 is of datatype Char(10) in the database. This query execution is throwing the error "SQLSTATE = 37000 [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Argument data type text is invalid for argument 1 of upper function."
I tried using convert function as below and it is successful:
SELECT IsNull(col1,'') INTO :ls_pwd
FROM tab_name
WHERE Upper(col2) = Upper(Convert(VARCHAR(MAX),:struct.id)
USING SQLCA;
But this solution is not feasible as the application has wide number of such queries and structures. Is there any good solution for this issue?
--Thanks,
Suhas.
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.