| 237 | } |
| 238 | |
| 239 | int main() |
| 240 | { |
| 241 | int rc = 0; |
| 242 | |
| 243 | // set default password if none specified in environment |
| 244 | setenv("ISC_USER", "sysdba", 0); |
| 245 | setenv("ISC_PASSWORD", "masterkey", 0); |
| 246 | |
| 247 | // With ThrowStatusWrapper passed as status interface FbException will be thrown on error |
| 248 | ThrowStatusWrapper status(master->getStatus()); |
| 249 | |
| 250 | // Declare pointers to required interfaces |
| 251 | IProvider* prov = master->getDispatcher(); |
| 252 | IUtil* utl = master->getUtilInterface(); |
| 253 | IAttachment* att = NULL; |
| 254 | ITransaction* tra = NULL; |
| 255 | IBatch* batch = NULL; |
| 256 | IBatchCompletionState* cs = NULL; |
| 257 | IXpbBuilder* pb = NULL; |
| 258 | |
| 259 | unsigned char streamBuf[10240]; // big enough for demo |
| 260 | unsigned char* stream = NULL; |
| 261 | |
| 262 | try |
| 263 | { |
| 264 | // attach employee db |
| 265 | att = prov->attachDatabase(&status, "employee", 0, NULL); |
| 266 | tra = att->startTransaction(&status, 0, NULL); |
| 267 | |
| 268 | // cleanup |
| 269 | att->execute(&status, tra, 0, "delete from project where proj_id like 'BAT%'", SAMPLES_DIALECT, |
| 270 | NULL, NULL, NULL, NULL); |
| 271 | |
| 272 | // |
| 273 | printf("\nPart 1. Simple messages. Adding one by one or by groups of messages, cancel batch.\n"); |
| 274 | // |
| 275 | |
| 276 | // Message to store in a table |
| 277 | FB_MESSAGE(Msg1, ThrowStatusWrapper, |
| 278 | (FB_VARCHAR(5), id) |
| 279 | (FB_VARCHAR(10), name) |
| 280 | ) project1(&status, master); |
| 281 | project1.clear(); |
| 282 | IMessageMetadata* meta = project1.getMetadata(); |
| 283 | |
| 284 | // sizes & alignments |
| 285 | unsigned mesAlign = meta->getAlignment(&status); |
| 286 | unsigned mesLength = meta->getMessageLength(&status); |
| 287 | unsigned char* streamStart = align(streamBuf, mesAlign); |
| 288 | |
| 289 | // set batch parameters |
| 290 | pb = utl->getXpbBuilder(&status, IXpbBuilder::BATCH, NULL, 0); |
| 291 | // collect per-message statistics |
| 292 | pb->insertInt(&status, IBatch::TAG_RECORD_COUNTS, 1); |
| 293 | |
| 294 | // create batch |
| 295 | const char* sqlStmt1 = "insert into project(proj_id, proj_name) values(?, ?)"; |
| 296 | batch = att->createBatch(&status, tra, 0, sqlStmt1, SAMPLES_DIALECT, meta, |
nothing calls this directly
no test coverage detected