| 38 | static IMaster* master = fb_get_master_interface(); |
| 39 | |
| 40 | int main() |
| 41 | { |
| 42 | int rc = 0; |
| 43 | |
| 44 | // set default password if none specified in environment |
| 45 | setenv("ISC_USER", "sysdba", 0); |
| 46 | setenv("ISC_PASSWORD", "masterkey", 0); |
| 47 | |
| 48 | // status vector and main dispatcher |
| 49 | ThrowStatusWrapper status(master->getStatus()); |
| 50 | IProvider* prov = master->getDispatcher(); |
| 51 | IUtil* utl = master->getUtilInterface(); |
| 52 | |
| 53 | // declare pointers to required interfaces |
| 54 | IAttachment* att = NULL; |
| 55 | ITransaction* tra = NULL; |
| 56 | IStatement* stmt = NULL; |
| 57 | IMessageMetadata* meta = NULL; |
| 58 | IMetadataBuilder* builder = NULL; |
| 59 | IXpbBuilder* tpb = NULL; |
| 60 | |
| 61 | // Interface provides access to data returned by SELECT statement |
| 62 | IResultSet* curs = NULL; |
| 63 | |
| 64 | try |
| 65 | { |
| 66 | // attach employee db |
| 67 | att = prov->attachDatabase(&status, "employee", 0, NULL); |
| 68 | |
| 69 | // start read only transaction |
| 70 | tpb = utl->getXpbBuilder(&status, IXpbBuilder::TPB, NULL, 0); |
| 71 | tpb->insertTag(&status, isc_tpb_read_committed); |
| 72 | tpb->insertTag(&status, isc_tpb_no_rec_version); |
| 73 | tpb->insertTag(&status, isc_tpb_wait); |
| 74 | tpb->insertTag(&status, isc_tpb_read); |
| 75 | tra = att->startTransaction(&status, tpb->getBufferLength(&status), tpb->getBuffer(&status)); |
| 76 | |
| 77 | // prepare statement |
| 78 | stmt = att->prepare(&status, tra, 0, "select last_name, first_name, phone_ext from phone_list " |
| 79 | "where location = 'Monterey' order by last_name, first_name", |
| 80 | SAMPLES_DIALECT, IStatement::PREPARE_PREFETCH_METADATA); |
| 81 | |
| 82 | // get list of columns |
| 83 | meta = stmt->getOutputMetadata(&status); |
| 84 | builder = meta->getBuilder(&status); |
| 85 | unsigned cols = meta->getCount(&status); |
| 86 | |
| 87 | // struct to cache received metadata |
| 88 | struct MyField |
| 89 | { |
| 90 | const char* name; |
| 91 | unsigned length, offset; |
| 92 | }; |
| 93 | MyField* fields = new MyField[cols]; |
| 94 | memset(fields, 0, sizeof(MyField) * cols); |
| 95 | |
| 96 | // parse columns list & coerce datatype(s) |
| 97 | for (unsigned j = 0; j < cols; ++j) |
nothing calls this directly
no test coverage detected