| 1202 | } |
| 1203 | |
| 1204 | static cell_t SQL_FetchInt(IPluginContext *pContext, const cell_t *params) |
| 1205 | { |
| 1206 | IQuery *query; |
| 1207 | HandleError err; |
| 1208 | |
| 1209 | if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None) |
| 1210 | { |
| 1211 | return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err); |
| 1212 | } |
| 1213 | |
| 1214 | IResultSet *rs = query->GetResultSet(); |
| 1215 | if (!rs) |
| 1216 | { |
| 1217 | return pContext->ThrowNativeError("No current result set"); |
| 1218 | } |
| 1219 | |
| 1220 | IResultRow *row = rs->CurrentRow(); |
| 1221 | if (!row) |
| 1222 | { |
| 1223 | return pContext->ThrowNativeError("Current result set has no fetched rows"); |
| 1224 | } |
| 1225 | |
| 1226 | int iv; |
| 1227 | DBResult res = row->GetInt(params[2], &iv); |
| 1228 | |
| 1229 | if (res == DBVal_Error) |
| 1230 | { |
| 1231 | return pContext->ThrowNativeError("Error fetching data from field %d", params[2]); |
| 1232 | } else if (res == DBVal_TypeMismatch) { |
| 1233 | return pContext->ThrowNativeError("Could not fetch data in field %d as an integer", params[2]); |
| 1234 | } |
| 1235 | |
| 1236 | cell_t *addr; |
| 1237 | pContext->LocalToPhysAddr(params[3], &addr); |
| 1238 | *addr = (cell_t)res; |
| 1239 | |
| 1240 | return iv; |
| 1241 | } |
| 1242 | |
| 1243 | static cell_t SQL_IsFieldNull(IPluginContext *pContext, const cell_t *params) |
| 1244 | { |
nothing calls this directly
no test coverage detected