简体   繁体   中英

Executing stored procedure with ODB ORM

There is a procedure stored on Microsoft SQL Server. Procedure can return a value. How can I execute stored procedure from MS SQL Server Database with ODB ORM and fetch value returned by this procedure?

You can use a native view for that. See Chapter 10, "Views" in the ODB manual for details.

Correct solution for calling stored procedure is the following

#pragma db view query("exec MyStoredProc (?);")
struct StoredProc
{
    int Result;
    std::string Comment;
};


.
.
.


typedef odb::result<StoredProc> Result;
typedef odb::query<StoredProc>  Query;

.
.
.

Result r( db.query<StoredProc>( Query::_val(param1) + ", "
        + Query::_val(param2) ) ) );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM