From 5e113195591a9f8dccbb8f5f743cdd7776906b08 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 Jan 2013 16:01:06 +0200 Subject: Add support for MSSQL ROWVERSION ODB can now use ROWVERSION column as an optimistic concurrency version. --- odb/mssql/statement.hxx | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'odb/mssql/statement.hxx') diff --git a/odb/mssql/statement.hxx b/odb/mssql/statement.hxx index 4b54097..e51cd3c 100644 --- a/odb/mssql/statement.hxx +++ b/odb/mssql/statement.hxx @@ -200,12 +200,14 @@ namespace odb insert_statement (connection_type& conn, const std::string& text, binding& param, - bool returning); + bool returning_id, + bool returning_version); insert_statement (connection_type& conn, const char* text, binding& param, - bool returning, + bool returning_id, + bool returning_version, bool copy_text = true); // Return true if successful and false if the row is a duplicate. @@ -220,6 +222,9 @@ namespace odb return id_; } + unsigned long long + version (); + private: insert_statement (const insert_statement&); insert_statement& operator= (const insert_statement&); @@ -229,10 +234,15 @@ namespace odb init_result (); private: - bool returning_; + bool returning_id_; + bool returning_version_; bool batch_; + unsigned long long id_; SQLLEN id_size_ind_; + + unsigned char version_[8]; + SQLLEN version_size_ind_; }; class LIBODB_MSSQL_EXPORT update_statement: public statement @@ -243,19 +253,34 @@ namespace odb update_statement (connection_type& conn, const std::string& text, - binding& param); + binding& param, + bool returning_version); update_statement (connection_type& conn, const char* text, binding& param, + bool returning_version, bool copy_text = true); unsigned long long execute (); + unsigned long long + version (); + private: update_statement (const update_statement&); update_statement& operator= (const update_statement&); + + private: + void + init_result (); + + private: + bool returning_version_; + + unsigned char version_[8]; + SQLLEN version_size_ind_; }; class LIBODB_MSSQL_EXPORT delete_statement: public statement @@ -283,6 +308,8 @@ namespace odb } } +#include + #include #endif // ODB_MSSQL_STATEMENT_HXX -- cgit v1.1