本文整理汇总了C++中IQuery::GetResultSet方法的典型用法代码示例。如果您正苦于以下问题:C++ IQuery::GetResultSet方法的具体用法?C++ IQuery::GetResultSet怎么用?C++ IQuery::GetResultSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQuery
的用法示例。
在下文中一共展示了IQuery::GetResultSet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SQL_FieldNumToName
static cell_t SQL_FieldNumToName(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
unsigned int field = params[2];
const char *fldname;
if ((fldname = rs->FieldNumToName(field)) == NULL)
{
return pContext->ThrowNativeError("Invalid field index %d", field);
}
pContext->StringToLocalUTF8(params[3], params[4], fldname, NULL);
return 1;
}
示例2: SQL_FetchSize
static cell_t SQL_FetchSize(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
IResultRow *row = rs->CurrentRow();
if (!row)
{
return pContext->ThrowNativeError("Current result set has no fetched rows");
}
if ((unsigned)params[2] >= rs->GetFieldCount())
{
return pContext->ThrowNativeError("Invalid field index %d", params[2]);
}
return row->GetDataSize(params[2]);
}
示例3: SQL_HasResultSet
static cell_t SQL_HasResultSet(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
return query->GetResultSet() != NULL ? true : false;
}
示例4: SQL_FetchRow
static cell_t SQL_FetchRow(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
return (rs->FetchRow() != NULL) ? true : false;
}
示例5: SQL_GetFieldCount
static cell_t SQL_GetFieldCount(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return 0;
}
return rs->GetFieldCount();
}
示例6: SQL_FetchString
static cell_t SQL_FetchString(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
IResultRow *row = rs->CurrentRow();
if (!row)
{
return pContext->ThrowNativeError("Current result set has no fetched rows");
}
const char *str;
size_t length;
DBResult res = row->GetString(params[2], &str, &length);
if (res == DBVal_Error)
{
return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
} else if (res == DBVal_TypeMismatch) {
return pContext->ThrowNativeError("Could not fetch data in field %d as a string", params[2]);
}
pContext->StringToLocalUTF8(params[3], params[4], str, &length);
cell_t *addr;
pContext->LocalToPhysAddr(params[5], &addr);
*addr = (cell_t)res;
return (cell_t)length;
}
示例7: SQL_FetchInt
static cell_t SQL_FetchInt(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
IResultRow *row = rs->CurrentRow();
if (!row)
{
return pContext->ThrowNativeError("Current result set has no fetched rows");
}
int iv;
DBResult res = row->GetInt(params[2], &iv);
if (res == DBVal_Error)
{
return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
} else if (res == DBVal_TypeMismatch) {
return pContext->ThrowNativeError("Could not fetch data in field %d as an integer", params[2]);
}
cell_t *addr;
pContext->LocalToPhysAddr(params[3], &addr);
*addr = (cell_t)res;
return iv;
}
示例8: SQL_FieldNameToNum
static cell_t SQL_FieldNameToNum(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
char *field;
pContext->LocalToString(params[2], &field);
cell_t *num;
pContext->LocalToPhysAddr(params[3], &num);
return rs->FieldNameToNum(field, (unsigned int *)num) ? 1 : 0;
}