| 128 | } |
| 129 | |
| 130 | int main() |
| 131 | { |
| 132 | int rc = 0; |
| 133 | |
| 134 | // set default password if none specified in environment |
| 135 | setenv("ISC_USER", "sysdba", 0); |
| 136 | setenv("ISC_PASSWORD", "masterkey", 0); |
| 137 | |
| 138 | // With ThrowStatusWrapper passed as status interface FbException will be thrown on error |
| 139 | ThrowStatusWrapper status(master->getStatus()); |
| 140 | |
| 141 | // Declare pointers to required interfaces |
| 142 | IProvider* prov = master->getDispatcher(); |
| 143 | IAttachment* att = NULL; |
| 144 | ITransaction* tra = NULL; |
| 145 | Event* event = NULL; |
| 146 | |
| 147 | try |
| 148 | { |
| 149 | // attach database |
| 150 | att = prov->attachDatabase(&status, "employee", 0, NULL); |
| 151 | |
| 152 | // register an event |
| 153 | event = new Event(att, "EVENT1"); |
| 154 | event->addRef(); |
| 155 | |
| 156 | const char cmdBlock[] = "execute block as begin post_event 'EVENT1'; end"; |
| 157 | |
| 158 | for (int i = 0; i < 3; ++i) |
| 159 | { |
| 160 | #ifndef WIN32 |
| 161 | sleep(1); // sec |
| 162 | #else |
| 163 | Sleep(1000); // msec |
| 164 | #endif |
| 165 | event->process(i); |
| 166 | |
| 167 | tra = att->startTransaction(&status, 0, NULL); |
| 168 | att->execute(&status, tra, 0, cmdBlock, SAMPLES_DIALECT, |
| 169 | NULL, NULL, NULL, NULL); |
| 170 | tra->commit(&status); |
| 171 | tra = NULL; |
| 172 | } |
| 173 | |
| 174 | // cleanup |
| 175 | event->release(); |
| 176 | event = NULL; |
| 177 | att->detach(&status); |
| 178 | att = NULL; |
| 179 | } |
| 180 | catch (const FbException& error) |
| 181 | { |
| 182 | // handle error |
| 183 | rc = 1; |
| 184 | |
| 185 | char buf[256]; |
| 186 | master->getUtilInterface()->formatStatus(buf, sizeof(buf), error.getStatus()); |
| 187 | fprintf(stderr, "%s\n", buf); |
nothing calls this directly
no test coverage detected