[odb-users] (no subject)

Boris Kolpackov boris at codesynthesis.com
Wed Jul 9 07:17:58 EDT 2014


Hi,

Евгений Демьянов <demianov314 at yandex.ru> writes:

> I using odb-3.2.0 with Microsoft SQL Server. I try to execute stored
> procedure using the folowing statement
> 
> #pragma db view
> struct ProcResult
> {
>     int Result;
>     std::string Comment;
> };
> 
> std::stringstream raw_query;
> raw_query << "exec Procedure" << value1 << ", " << value2 ; 
> 
> Result r ( db.query<ProcResult> (
>         raw_query.str().c_str() ) ) ;
> 
> But libodb-mssql-3.2.0 library automatically prepends "WHERE " keyword
> before native SQL string.

Try this:

#pragma db view query ("EXEC Procedure (?)")
struct ProcResult
{
    int Result;
    std::string Comment;
};

typedef odb::query<ProcResult> ProcQuery;

Result r (db.query<ProcResult> (
  ProcQuery::_val (value1) + "," + ProcQuery::_val (value2)));


> I temporary solved this problem by modifying function check_prefix in
> file query.cxx. I added conditions 
> s.compare (0, (n = 4), "EXEC") == 0 || s.compare (0, (n = 4), "exec") == 0.

I've added this change for the next release so that you will be able to
supply the EXEC statement for the native view at runtime.

Boris



More information about the odb-users mailing list