Skip to content

Commit

Permalink
Oracle backend: get_affected_rows() works
Browse files Browse the repository at this point in the history
Cherry-picked from pull request #75

Conflicts:
	src/backends/oracle/test/test-oracle.cpp
  • Loading branch information
vnaydionov authored and mloskot committed Feb 25, 2013
1 parent af1d62c commit 4aff358
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/backends/oracle/statement.cpp
Expand Up @@ -118,16 +118,25 @@ statement_backend::exec_fetch_result oracle_statement_backend::fetch(int number)

long long oracle_statement_backend::get_affected_rows()
{
// ...
return -1;
ub4 row_count;
sword res = OCIAttrGet(static_cast<dvoid*>(stmtp_),
OCI_HTYPE_STMT, &row_count,
0, OCI_ATTR_ROW_COUNT, session_.errhp_);

if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}

return row_count;
}

int oracle_statement_backend::get_number_of_rows()
{
int rows;
sword res = OCIAttrGet(static_cast<dvoid*>(stmtp_),
static_cast<ub4>(OCI_HTYPE_STMT), static_cast<dvoid*>(&rows),
0, static_cast<ub4>(OCI_ATTR_ROWS_FETCHED), session_.errhp_);
OCI_HTYPE_STMT, static_cast<dvoid*>(&rows),
0, OCI_ATTR_ROWS_FETCHED, session_.errhp_);

if (res != OCI_SUCCESS)
{
Expand Down
12 changes: 10 additions & 2 deletions src/backends/oracle/test/test-oracle.cpp
Expand Up @@ -1112,6 +1112,15 @@ struct table_creator_three : public table_creator_base
}
};

struct table_creator_four : public table_creator_base
{
table_creator_four(session & sql)
: table_creator_base(sql)
{
sql << "create table soci_test(val number)";
}
};

class test_context :public test_context_base
{
public:
Expand All @@ -1136,8 +1145,7 @@ class test_context :public test_context_base

table_creator_base* table_creator_4(session& s) const
{
// get_affected_rows not implemented in Oracle backend
return 0;
return new table_creator_four(s);
}

std::string to_date_time(std::string const &datdt_string) const
Expand Down

0 comments on commit 4aff358

Please sign in to comment.