I'm also getting the "Mismatch between retrieve columns and fetch columns" error when calling a sql server proc with output parm. These are the particulars:
PB 2017 R2
See attached for SQL Server specs
It's important to note that the PB app has other stored proc calls with same format as this call and they work fine.
PB Code:
Var li_update is integer
// Run the stored proc to reprocess if update was successful.
// The proc returns 1 for success and 0 for failure in OUTPUT parm.
// The proc does its own transaction processing.
DECLARE ap_Meter_Ticket_Process PROCEDURE FOR dbo.ap_Meter_Ticket_Process
@IsReprocess = :ls_fl_reprocess,
@Id_user = :ls_id_user,
@rtn = :li_update OUTPUT;
EXECUTE ap_Meter_Ticket_Process;
if sqlca.sqlcode = 0 then
// Retrieve proc return code
FETCH ap_Meter_Ticket_Process INTO :li_update;
if sqlca.sqlcode <> 0 then
// Fetch Failure
li_update = -1
ls_sql_msg = sqlca.sqlerrtext
else
// Fetch Success
if li_update = 0 then
// Reprocess failed
ls_sql_msg = "Refer to email for failure details"
end if
end if
else
li_update = -1
ls_sql_msg = sqlca.sqlerrtext
end if
CLOSE ap_Meter_Ticket_Process;
SQL Server Code:
All parms have a default value as the proc is called from a SQL Agent job without parms
Var @rtn defaults to 1 for success and if the proc encounters any error situations, @rtn gets set to 0 for failure
ALTER proc [dbo].[ap_Meter_Ticket_Process]
(
@IsReprocess varchar(1) = 'N',
@Id_user varchar(30) = 'NONE',
@rtn int = 1 OUTPUT
)
Any help is appreciated
Pete
sqlca.database = sle_database.Text
sqlca.servername = sle_server.Text
sqlca.dbparm = sle_dbparm.Text
sqlca.dbparm = "OJSYNTAX='ANSI'"
sqlca.logid = sle_userid.Text
sqlca.logpass = sle_dbpass.Text
sqlca.userid = sle_userid.Text
sqlca.dbpass = sle_dbpass.Text
SQLCA.DBMS = "SNC"
SQLCA.ServerName = "xxxxxxx\xxxxxx"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Database='xxxxxx',Provider='SQLNCLI11',TrimSpaces=1,DateFormat='mm/dd/yyyy',TimeFormat='hh:mm:ss'"
TrimSpaces=1 trims trailing spaces from CHAR data. ANSI outer join syntax is the default, so no need to specify it. We turn AutoCommit off. We explicitly set the date and time formats. The SQLNCLI11 provider is for use with SQL Server 2012 and later (we are using SS2017).
Since I'm not familiar with your application, I cannot recommend any particular settings, but you might wish to experiment with some of these values, particularly the Date and Time format settings and the Provider setting. Let us know how it goes.
I added the parms you had in the DBParm string and it worked! Thank you very much for your help!