#include <rw/db/datacb.h>
#include <rw/db/db.h>
#include <rw/db/tbuffer.h>
using namespace std;
const size_t LENGTH = 20000;
const size_t PIECES = 3;
public:
MyCallback(size_t rowsetSize)
virtual ~MyCallback() {}
bool onFetch(size_t rownum, const char* theData, size_t length,
cout << endl << "Row in rowset is: " << rownum << endl;
cout << "Row in result set is: " << (rownum + offset) << endl;
if (ni) {
cout << "Read a null" << endl;
} else if (lastPiece) {
cout << "Read a piece of data of length " << length << endl;
cout << "Received the last piece of data for row " << rownum
<< endl;
} else {
cout << "Read a piece of data of length " << length << endl;
}
return true;
}
bool onSend(size_t rownum, char* theData, size_t& length,
static size_t piecesSent = 0;
length = LENGTH;
memcpy((void*)theData, tmp.data(), LENGTH);
++piecesSent;
if (piecesSent == PIECES) {
lastPiece = true;
piecesSent = 0;
}
return true;
}
size_t getLength(size_t rownum) const { return LENGTH * PIECES; }
void addToRowOffset(size_t rowsFetched) { offset += rowsFetched; }
void setOffset(size_t newValue) { offset = newValue; }
private:
size_t offset;
};
int main() {
"msq8015d.dll", "SQL SERVER DB", "username", "password", "DB");
} else {
}
MyCallback cbin(5);
RWDBOSql sql(
"insert into " + tableName +
" values(?)");
sql << cbin;
sql.execute(cn);
if (sql.isValid()) {
cout << "inserted 5 rows" << endl;
} else {
cout << "inserting rows failed" << endl;
}
sql.execute(cn);
if (sql.isValid()) {
cout << "inserted another 5 rows" << endl;
} else {
cout << "inserting another 5 rows failed" << endl;
}
MyCallback cbout(3);
sql.statement("select * from " + tableName);
sql.execute(cn);
if (sql.isValid()) {
sql[0] >> cbout;
while (sql.fetch(), sql.rowsFetched() > 0) {
cbout.addToRowOffset(sql.rowsFetched());
}
}
return 0;
}
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
Base class for user-defined callback methods that fetch and send character data.
Definition datacb.h:279
Represents an explicit database connection object that can be used in place of the implicit database ...
Definition connect.h:81
Manages connections with database servers.
Definition dbase.h:91
RWDBTable table(const RWCString &name) const
RWDBStatus createTable(const RWDBTable &table) const
Encapsulates an SQL DELETE statement.
Definition deleter.h:92
static RWDBDatabase database(const RWCString &serverType, const RWCString &serverName, const RWCString &userName, const RWCString &password, const RWCString &databaseName, const RWDBDatabaseCallback &databasecb=RWDBDatabaseCallback())
Provides a way to determine whether some given data is NULL.
Definition nullind.h:86
Encapsulates a database-specific SQL statement with all its input and output bindings.
Definition osql.h:209
An ordered collection of RWDBColumn instances, encapsulating the database notion of a schema.
Definition schema.h:62
RWDBColumn appendColumn(const RWCString &name, RWDBValue::ValueType type=RWDBValue::NoType, long storageLength=RWDB_NO_TRAIT, int nativeType=RWDB_NO_TRAIT, int precision=RWDB_NO_TRAIT, int scale=RWDB_NO_TRAIT, bool nullAllowed=true, RWDBColumn::ParamType paramType=RWDBColumn::notAParameter)
Base class for a family of classes that represent the abstract notion of a database table in a number...
Definition table.h:89
bool exists(bool forceLookup=false)
RWDBDeleter deleter() const
@ String
Definition value.h:241