Based on the provided information, it seems that there might be an issue with how the output parameters are bound or how the stored procedure is being called. Here are a few things to check and consider:
- SQL Server Stored Procedure Definition: Verify that the stored procedure
est_procis correctly defined in SQL Server and that it indeed has three output parameters:
action. Ensure that the data types and sizes of the output parameters match the ones used in the C program.
- SQLBindParameter Parameters: Check the parameters passed to the SQLBindParameter function. Ensure that the parameter numbers and data types match the ones expected by the stored procedure. For example, ensure that the parameter number for
retValueis 1, for
countis 3, and for
- Error Handling: Check for any error codes returned by the ODBC functions, including SQLBindParameter and SQLExecDirect. Make sure to handle any potential errors appropriately. You can use SQLGetDiagRec to retrieve error information for diagnosis.
- Output Buffer Sizes: Ensure that the output buffer sizes for the variables
actionare large enough to hold the data returned by the stored procedure. The buffer size should be at least the size of the data type.
- ODBC Driver Compatibility: Verify that the version of the MS ODBC driver 18 for SQL Server (msodbcsql18-22.214.171.124-1.x86_64.rpm) is compatible with SQL Server 2019. It's essential to use a compatible ODBC driver version with the corresponding SQL Server version.
- Stored Procedure Execution: Double-check that the stored procedure is executed correctly using the SQLExecDirect function. Ensure that the parameters are passed in the correct order and that the procedure is called as expected.
- Stored Procedure Behavior: Examine the behavior of the stored procedure itself. Make sure there are no issues with the logic inside the procedure that might affect the output parameter values.
- Debugging: Consider adding additional debug information in your C program to trace the values of the output parameters before and after the stored procedure call. This can help identify any unexpected behavior.
If you have verified all the above aspects and the issue persists, it might be helpful to consult the official documentation of the MS ODBC driver, review any relevant Microsoft support articles, or reach out to their support team for further assistance with the specific version of the ODBC driver and SQL Server being used.