Symptom
Recently migrated application from PowerBuilder 11.1 (build 8123) to PowerBuilder 2017 on Windows 7. The application is using Microsoft SQL Server and when calling a stored procedure using ODBC results in the error of "Invalid character value for cast specification".
The following dbparms are being used in the database connection:
- StripParmNames='Yes'
- CallEscape='No'.
Environment
- PowerBuilder
- Windows 7
- Microsoft SQL Server
Reproducing the Issue
- Create a stored procedure that passes an integer in and returns two strings on a Microsoft SQL Server database.
- Create a PB Build 11.1 Build 8123 application that has a non visual user object with a function that calls a stored procedure and then migrate it to PB 2017 like so:
- STRING ls_string1, ls_string2
DECLARE MyProc PROCEDURE FOR dbo.usp_test :al_number :ls_string1, :ls_string2;
EXECUTE MyProc;
- STRING ls_string1, ls_string2
The script returns an error for the customer.
Cause
From the Connection Reference Manual, PBNewSPInvocation uses an alternative method to invoke a stored procedure.
The values are:
- No - (Default) Use the standard method to invoke a stored procedure
- Yes - Use the alternative method to invoke a stored procedure
The application was using the default value of No for PBNewSPInvocation.
Resolution
For the database connection, the following dbparms resolved the error:
SQLCA.DBParm="ConnectString='DSN=MyAppDSN;UID=xxx;PWD=xxx',PBNewSPInvocation='Yes',CallEscape='No',StripParmNames='Yes'"