[unixODBC-dev] Calling a store procedure

Nick Gorham nick at lurcher.org
Thu Feb 23 08:29:52 GMT 2012

On 23/02/2012 03:05, Jaime Stuardo wrote:
> Hello... I am trying to call a SQL Server 2005 stored procedure by 
> mean of a C++ application running under RedHat Linux. unixODBC is 
> installed correctly since I can connect to the database.
> When I run SQLExecDirect, the returned value is an error. So, here are 
> the questions:
> ·Why does an error occur?
> ·Why does the SQLGetDiagRec function cannot return the actual error? 
> If I generate an error passing a string instead of a date in the 
> second parameter, the error is: [FreeTDS][SQL Server]Error converting 
> data type varchar to datetime. That means ExtractError function I 
> implemented is correct.
> This is the code with SQLExecDirect:
>     ret = SQLExecDirect(stmt, (SQLCHAR *) query.c_str(), SQL_NTS);
>     if (!SQL_SUCCEEDED(ret)) {
>         StoreSocket::ExtractError("SQLExecDirect", stmt, SQL_HANDLE_STMT);
>         return false;
>     }
> Where query is:
> execute usp_contrato_actualiza_aclaracion 'uno', '2012-02-22', 'dos', 
> 'tres', 'cuatro', '2012-02-14', 'cinco', 'seis', 'siete', 'ocho', 
> 'nueve', 'diez', 'once'
> And the body of ExtractError is:


Not sure I understand the problem, maybe if you could create a full test 
program with definition of the procedure and the expected and actual 
error it may help. I would guess its going to eventually be a question 
for the driver writers, but not sure at the moment. If you had a test 
program I could run I could try with another driver and see what the 
problem is.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-dev/attachments/20120223/154a55df/attachment.html>

More information about the unixODBC-dev mailing list