本文整理汇总了C++中dbnextrow函数的典型用法代码示例。如果您正苦于以下问题:C++ dbnextrow函数的具体用法?C++ dbnextrow怎么用?C++ dbnextrow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbnextrow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test0
static void
test0(int n, const char * expected)
{
DBINT ind, expected_ind;
char text_buf[16];
dbfcmd(dbproc, "select c from #null where n = %d", n);
dbsqlexec(dbproc);
if (dbresults(dbproc) != SUCCEED) {
fprintf(stderr, "Was expecting a row.\n");
failed = 1;
dbcancel(dbproc);
return;
}
dbbind(dbproc, 1, NTBSTRINGBIND, 0, (BYTE *)text_buf);
if (use_nullbind)
dbnullbind(dbproc, 1, &ind);
memset(text_buf, 'a', sizeof(text_buf));
ind = -5;
if (dbnextrow(dbproc) != REG_ROW) {
fprintf(stderr, "Was expecting a row.\n");
failed = 1;
dbcancel(dbproc);
return;
}
text_buf[sizeof(text_buf) - 1] = 0;
printf("ind %d text_buf -%s-\n", (int) ind, text_buf);
expected_ind = 0;
if (strcmp(expected, "aaaaaaaaaaaaaaa") == 0)
expected_ind = -1;
/* do not check indicator if not bound */
if (!use_nullbind)
ind = expected_ind;
if (ind != expected_ind || strcmp(expected, text_buf) != 0) {
fprintf(stderr, "expected_ind %d expected -%s-\n", (int) expected_ind, expected);
failed = 1;
dbcancel(dbproc);
return;
}
if (dbnextrow(dbproc) != NO_MORE_ROWS) {
fprintf(stderr, "Only one row expected\n");
dbcancel(dbproc);
failed = 1;
}
while (dbresults(dbproc) == SUCCEED) {
/* nop */
}
}
示例2: char_test
static void
char_test(const char *null, int bindlen, const char *expected)
{
char db_c[16];
RETCODE ret;
if (null) {
fprintf(stderr, "\tdbsetnull(CHARBIND, %u, '%s').\n", (unsigned int) strlen(null), null);
ret = dbsetnull(dbproc, CHARBIND, strlen(null), (BYTE *) null);
if (ret != SUCCEED) {
fprintf(stderr, "dbsetnull returned error %d\n", (int) ret);
failed = 1;
}
}
memset(db_c, '_', sizeof(db_c));
strcpy(db_c, "123456");
dbcmd(dbproc, "select convert(char(20), null)");
dbsqlexec(dbproc);
if (dbresults(dbproc) != SUCCEED) {
fprintf(stderr, "Was expecting a row.\n");
failed = 1;
dbcancel(dbproc);
}
fprintf(stderr, "dbbind(CHARBIND, bindlen= %d).\n", bindlen);
dbbind(dbproc, 1, CHARBIND, bindlen, (BYTE *) &db_c);
db_c[sizeof(db_c)-1] = 0;
printf("buffer before/after dbnextrow: '%s'/", db_c);
if (dbnextrow(dbproc) != REG_ROW) {
fprintf(stderr, "Was expecting a row.\n");
failed = 1;
dbcancel(dbproc);
}
db_c[sizeof(db_c)-1] = 0;
printf("'%s'\n", db_c);
if (dbnextrow(dbproc) != NO_MORE_ROWS) {
fprintf(stderr, "Only one row expected\n");
dbcancel(dbproc);
failed = 1;
}
while (dbresults(dbproc) == SUCCEED) {
/* nop */
}
if (strcmp(db_c, expected) != 0) {
fprintf(stderr, "Invalid NULL '%s' returned expected '%s' (%s:%d)\n", db_c, expected, tds_basename(__FILE__), __LINE__);
failed = 1;
}
}
示例3: delete_col_collector_db
int
delete_col_collector_db()
{
char *db_string;
int i = 0, ret_code;
dbcmd(dbproc1," delete COL_COLLECTOR ");
dbcmd(dbproc1, " where ");
db_string =
(char *)convert_to_db_string(col_collector_selected.collector_id);
dbfcmd(dbproc1, " collector_id = %d",
atoi(db_string));
free(db_string);
if(safe_dbupdate(dbproc1, "COL_COLLECTOR",
"delete_col_collector_db"))
{
return(FAILURE);
}
while ((ret_code = dbnextrow(dbproc1)) == REG_ROW)
{
if (ret_code == FAIL)
{
return(FAILURE);
}
}
if(check_dbresults(dbproc1,ret_code,"COL_COLLECTOR",
"delete_col_collector_db"))
return(FAILURE);
return(SUCCESS);
}
示例4: pp_mark_pkg_active
int pp_mark_pkg_active( int pkg_id, int pkg_inst_id, int pkg_inst_id_serv)
{
int status;
RETCODE ret_code;
dbcmd (dbproc1, "EXEC pp_mark_pkg_active ");
dbfcmd(dbproc1, " @pkg_inst_id = %d, ", pkg_inst_id);
dbfcmd(dbproc1, " @pkg_inst_id_serv = %d ", pkg_inst_id_serv);
if(safe_dbexec(dbproc1,"MARK_PKG_ACTIVE", "mark_pkg_active"))
return(FAILURE);
while ((status = safe_dbresults (dbproc1, "MARK_PKG_ACTIVE", "mark_pkg_active")) != NO_MORE_RESULTS)
{
if (status == FAIL) return(FAILURE);
while ((ret_code = dbnextrow(dbproc1)) != NO_MORE_ROWS)
{
if(ret_code == FAIL) return(FAILURE);
/* process results */
}
}
return (SUCCESS);
}
示例5: pp_add_inactive_pkg
int pp_add_inactive_pkg (int pkg_id, int *pkg_inst_id, int *pkg_inst_id_serv, char *start_date)
{
int track_id;
int serv_id;
int status;
int ret_code;
dbfcmd(dbproc1, "exec pp_insert_inactive_pkg @account_no = %d,",gaccount_no);
dbfcmd(dbproc1, " @pkg_id = %d, ", pkg_id);
dbfcmd(dbproc1, " @active_dt = '%s' ", start_date);
if(safe_dbexec(dbproc1,"INSERT_PKG", "insert_pkg"))
return(FAILURE);
while ((status = safe_dbresults (dbproc1, "INSERT_PKG", "insert_pkg")) != NO_MORE_RESULTS)
{
if (status == FAIL) return(FAILURE);
dbbind (dbproc1, 1, INTBIND, 0, &track_id);
dbbind (dbproc1, 2, INTBIND, 0, &serv_id);
while ((ret_code = dbnextrow(dbproc1)) != NO_MORE_ROWS)
{
if(ret_code == FAIL) return(FAILURE);
/* process results */
*pkg_inst_id = track_id;
*pkg_inst_id_serv = serv_id;
}
}
return (SUCCESS);
}
示例6: verify_terminate
int verify_terminate (int *ok_to_terminate)
{
RETCODE ret_code;
dbfcmd(dbproc1, "EXEC csr_verify_acct_terminate @account_no = %d",
gaccount_no);
br_dbsqlexec(dbproc1);
if (Sybase_error)
{
dbcancel(dbproc1);
return(FAILURE);
}
while ((ret_code = dbresults(dbproc1)) != NO_MORE_RESULTS)
{
if (ret_code != SUCCEED)
{
dbcancel(dbproc1);
return(FAILURE);
}
dbbind(dbproc1, 1, INTBIND, 0, ok_to_terminate);
while (dbnextrow(dbproc1) != NO_MORE_ROWS); /* empty */
}
if (Sybase_error)
{
dbcancel(dbproc1);
return(FAILURE);
}
return (SUCCESS);
} /* end verify_terminate */
示例7: init
static int
init(DBPROCESS * dbproc, const char *name)
{
int res = 0;
RETCODE rc;
fprintf(stdout, "Dropping %s.%s..%s\n", SERVER, DATABASE, name);
sql_cmd(dbproc);
dbsqlexec(dbproc);
while ((rc=dbresults(dbproc)) == SUCCEED) {
/* nop */
}
if (rc != NO_MORE_RESULTS)
return 1;
fprintf(stdout, "Creating %s.%s..%s\n", SERVER, DATABASE, name);
sql_cmd(dbproc);
sql_cmd(dbproc);
if (dbsqlexec(dbproc) == FAIL) {
res = 1;
}
while ((rc=dbresults(dbproc)) == SUCCEED) {
dbprhead(dbproc);
dbprrow(dbproc);
while ((rc=dbnextrow(dbproc)) == REG_ROW) {
dbprrow(dbproc);
}
}
if (rc != NO_MORE_RESULTS)
return 1;
fprintf(stdout, "%s\n", res? "error" : "ok");
return res;
}
示例8: verify_provider_class
/* verify that the provider class is valid(exist in PROVIDER_CLASS_REF) */
int
verify_provider_class(RATE_USAGE_OVERRIDES_STRUCT *struct_ptr, int *count)
{
int i=0;
int ret_code;
dbcmd(dbproc1, " select count(*) ");
dbcmd(dbproc1, " from PROVIDER_CLASS_REF ");
dbfcmd(dbproc1, " where provider_class = %s", struct_ptr->provider_class);
if (safe_dbselect(dbproc1, "PROVIDER_CLASS_REF",
"verify_provider_class"))
{
return(FAILURE);
}
dbbind(dbproc1,1,INTBIND,0, count);
while (dbnextrow(dbproc1) == REG_ROW)
{
i++;
} /* end of while loop */
if(check_dbresults(dbproc1,ret_code,"PROVIDER_CLASS_REF",
"verify_provider_class"))
{
return(FAILURE);
}
return (SUCCESS);
}
示例9: verify_type_id_usg
int
verify_type_id_usg(RATE_USAGE_OVERRIDES_STRUCT *struct_ptr, int *count)
{
int i=0;
int ret_code;
dbcmd(dbproc1, " select count(*) ");
dbcmd(dbproc1, " from USAGE_TYPES ");
dbfcmd(dbproc1, " where type_id_usg = %s", struct_ptr->type_id_usg);
if (safe_dbselect(dbproc1, "USAGE_TYPES",
"verify_type_id_usg"))
{
return(FAILURE);
}
dbbind(dbproc1,1,INTBIND,0, count);
while (dbnextrow(dbproc1) == REG_ROW)
{
i++;
} /* end of while loop */
if(check_dbresults(dbproc1,ret_code,"USAGE_TYPES",
"verify_type_id_usg"))
{
return(FAILURE);
}
return (SUCCESS);
}
示例10: dblib_handle_doer
static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
RETCODE ret, resret;
dbsetuserdata(H->link, (BYTE*)&H->err);
if (FAIL == dbcmd(H->link, sql)) {
return -1;
}
if (FAIL == dbsqlexec(H->link)) {
return -1;
}
resret = dbresults(H->link);
if (resret == FAIL) {
return -1;
}
ret = dbnextrow(H->link);
if (ret == FAIL) {
return -1;
}
if (dbnumcols(H->link) <= 0) {
return DBCOUNT(H->link);
}
/* throw away any rows it might have returned */
dbcanquery(H->link);
return DBCOUNT(H->link);
}
示例11: get_all
void get_all(char *mitnr_in)
{
dbfcmd(dbproc,"SELECT m.Name, m.Vorname, m.Ort, m.Gebdat, m.Beruf, m.Telnr, mp.Istvzae, mp.Planvzae, p.Proname FROM Mitarbeiter m, MiPro mp, Projekt p WHERE m.Mitnr = mp.Mitnr AND mp.Pronr = p.Pronr AND m.Mitnr = '%s'", mitnr_in);
dbsqlexec(dbproc);
while (dbresults(dbproc)!=NO_MORE_RESULTS)
{
i=0;
dbbind(dbproc,1,NTBSTRINGBIND,0,name);
dbbind(dbproc,2,NTBSTRINGBIND,0,vorname);
dbbind(dbproc,3,NTBSTRINGBIND,0,ort);
dbbind(dbproc,4,DATETIMEBIND,0,(BYTE *)&gebdat);
dbbind(dbproc,5,NTBSTRINGBIND,0,beruf);
dbbind(dbproc,6,NTBSTRINGBIND,0,telnr);
dbbind(dbproc,7,FLT8BIND,0,(BYTE *)&istvzae);
dbbind(dbproc,8,FLT8BIND,0,(BYTE *)&planvzae);
dbbind(dbproc,9,NTBSTRINGBIND,0,proname);
while (dbnextrow(dbproc)!=NO_MORE_ROWS)
{
printf("%d:\t%s,\t%s,\t%s,\t%s,\t%s,\t%s,\t%f,\t%f,\t%s,\n",i, name, vorname, ort, date_to_str(gebdat), beruf, telnr, istvzae, planvzae, proname);
i++;
}
}
}
示例12: select_rows
static int
select_rows(DBPROCESS * dbproc, int bind_type)
{
char teststr[1024];
char teststr2[1024];
char testvstr[1024];
DBINT testint;
DBINT i;
printf("select\n");
sql_cmd(dbproc);
dbsqlexec(dbproc);
if (dbresults(dbproc) != SUCCEED) {
failed = 1;
printf("Was expecting a result set.");
exit(1);
}
for (i = 1; i <= dbnumcols(dbproc); i++) {
printf("col %d is %s\n", i, dbcolname(dbproc, i));
}
if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) {
fprintf(stderr, "Had problem with bind\n");
return 1;
}
if (SUCCEED != dbbind(dbproc, 2, bind_type, 0, (BYTE *) teststr)) {
fprintf(stderr, "Had problem with bind\n");
return 1;
}
if (SUCCEED != dbbind(dbproc, 3, bind_type, 0, (BYTE *) teststr2)) {
fprintf(stderr, "Had problem with bind\n");
return 1;
}
if (SUCCEED != dbbind(dbproc, 4, bind_type, 0, (BYTE *) testvstr)) {
fprintf(stderr, "Had problem with bind\n");
return 1;
}
i = 0;
while (dbnextrow(dbproc) == REG_ROW) {
i++;
if (testint != i) {
printf("Failed. Expected i to be |%d|, was |%d|\n", testint, i);
return 1;
}
printf("c: %s$\n", teststr);
printf("c2: %s$\n", teststr2);
printf("vc: %s$\n", testvstr);
if (bind_type == STRINGBIND) {
} else {
}
}
return 0;
}
示例13: dbnextrow
bool QTDSResult::gotoNext(QSqlCachedResult::ValueCache &values, int index)
{
STATUS stat = dbnextrow(d->dbproc);
if (stat == NO_MORE_ROWS) {
setAt(QSql::AfterLastRow);
return false;
}
if ((stat == FAIL) || (stat == BUF_FULL)) {
setLastError(d->lastError);
return false;
}
if (index < 0)
return true;
for (int i = 0; i < d->rec.count(); ++i) {
int idx = index + i;
switch (d->rec.field(i).type()) {
case QVariant::DateTime:
if (qIsNull(d->buffer.at(i * 2 + 1))) {
values[idx] = QVariant(QVariant::DateTime);
} else {
DBDATETIME *bdt = (DBDATETIME*) d->buffer.at(i * 2);
QDate date = QDate::fromString(QLatin1String("1900-01-01"), Qt::ISODate);
QTime time = QTime::fromString(QLatin1String("00:00:00"), Qt::ISODate);
values[idx] = QDateTime(date.addDays(bdt->dtdays), time.addMSecs(int(bdt->dttime / 0.3)));
}
break;
case QVariant::Int:
if (qIsNull(d->buffer.at(i * 2 + 1)))
values[idx] = QVariant(QVariant::Int);
else
values[idx] = *((int*)d->buffer.at(i * 2));
break;
case QVariant::Double:
case QVariant::String:
if (qIsNull(d->buffer.at(i * 2 + 1)))
values[idx] = QVariant(QVariant::String);
else
values[idx] = QString::fromLocal8Bit((const char*)d->buffer.at(i * 2)).trimmed();
break;
case QVariant::ByteArray: {
if (qIsNull(d->buffer.at(i * 2 + 1)))
values[idx] = QVariant(QVariant::ByteArray);
else
values[idx] = QByteArray((const char*)d->buffer.at(i * 2));
break;
}
default:
// should never happen, and we already fired
// a warning while binding.
values[idx] = QVariant();
break;
}
}
return true;
}
示例14: fetch_results
void Query::execute( Connector *conn, string s_query)
{
this->connector = conn;
this->query = s_query;
this->execute();
logger->debug("connector: %p, executing query: %s\n", conn, s_query.c_str());
if (!this->getStatus()){
logger->debug("Query failed.\n ");
} else {
logger->debug("fetching results..\n");
fetch_results();
bind_variables();// allocating and binding variables for iteration
vector<field>::iterator iter_f = v_fields.begin();
#ifdef MSSQL
while (dbnextrow(conn->conn_ptr) != NO_MORE_ROWS){
iter_f = v_fields.begin();
while(iter_f!=v_fields.end()){
if(iter_f->type!=field::TYPE_INT)
stripSpace(iter_f->data, iter_f->size);
iter_f++;
}
num_records++;
iterate(v_fields);
}
#endif
#ifdef WATCHLIST_MYSQL
if (res != NULL){// insert or update queries.
this->num_records = mysql_num_rows(res);
MYSQL_ROW row;
int pos;
if (res !=NULL && (num_records > 0))
while( ( row = mysql_fetch_row(res))){
// fetch each records
pos = 0;
iter_f = v_fields.begin();
while(iter_f!=v_fields.end()){
// iterating columns
if (iter_f->type==field::TYPE_INT){
iter_f->setData(atoi(row[pos]));
} else {
iter_f->setData(string(row[pos]));
}
pos++;
iter_f++;
}
iterate(v_fields);// passing to child
}
mysql_free_result(res);
}
#endif
}
logger->debug("completed execute\n");
}
示例15: eft_get_status_codes
void eft_get_status_codes()
{
int db_code;
char description[81];
RETCODE ret_code;
/* this gets called once and hangs around forever */
description[0] = '\0';
db_code = 0;
eft_num_display_statuses = 0;
if(eft_sel_shell == NULL)
create_eft_sel_shell(eft_shell);
dbcmd(dbeftproc,"select integer_value,display_value from GUI_INDICATOR_VALUES where ");
dbcmd(dbeftproc,"table_name = 'EFT_TRANS' and field_name = 'trans_status'");
dbfcmd(dbeftproc, " and language_code = %d", gGUIlanguage );
br_dbsqlexec(dbeftproc);
if (Sybase_error)
{
dbcancel(dbeftproc);
return;
}
while((ret_code = dbresults(dbeftproc)) != NO_MORE_RESULTS)
{
if(ret_code == FAIL)
{
dbcancel(dbeftproc);
return;
}
dbbind(dbeftproc,1,INTBIND,0,&db_code);
dbbind(dbeftproc,2,NTBSTRINGBIND,0,description);
while (dbnextrow(dbeftproc) != NO_MORE_ROWS)
{
/* Found an entry. */
eft_num_display_statuses++;
eft_display_statuses = (EFT_DB_POPLIST_TYPE *)
realloc (eft_display_statuses,eft_num_display_statuses * sizeof (EFT_DB_POPLIST_TYPE));
eft_display_statuses_list = (XmString *)
realloc (eft_display_statuses_list,eft_num_display_statuses * sizeof (XmString));
eft_display_statuses[eft_num_display_statuses - 1].db_code = db_code;
strcpy (eft_display_statuses[eft_num_display_statuses - 1].description,description);
eft_display_statuses_list[eft_num_display_statuses - 1] = XmStringCreateSimple (description);
}
}
if(Sybase_error)
{
dbcancel(dbeftproc);
return;
}
}