MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / main

Function main

examples/interfaces/05.user_metadata.cpp:204–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204int main()
205{
206 int rc = 0;
207 unsigned char* buffer = NULL;
208
209 // set default password if none specified in environment
210 setenv("ISC_USER", "sysdba", 0);
211 setenv("ISC_PASSWORD", "masterkey", 0);
212
213 // status vector and main dispatcher
214 ThrowStatusWrapper status(master->getStatus());
215 IProvider* prov = master->getDispatcher();
216
217 // declare pointers to required interfaces
218 IAttachment* att = NULL;
219 ITransaction* tra = NULL;
220 IResultSet* curs = NULL;
221 MyMetadata* meta = NULL;
222
223 try
224 {
225 // Instance of our metadata
226 meta = new MyMetadata;
227 meta->addRef();
228
229 // allocate output buffer
230 buffer = new unsigned char[meta->length];
231
232 // attach employee db
233 att = prov->attachDatabase(&status, "employee", 0, NULL);
234
235 // start default transaction
236 tra = att->startTransaction(&status, 0, NULL);
237
238 // open cursor
239 curs = att->openCursor(&status, tra, 0, "select current_user from rdb$database",
240 SAMPLES_DIALECT, NULL, NULL, meta, NULL, 0);
241
242 // fetch record from cursor and print it
243 curs->fetchNext(&status, buffer);
244 ISC_SHORT l = to<ISC_SHORT>(buffer, meta->offset);
245 printf("<%*.*s>\n", l, l, buffer + meta->offset + sizeof(ISC_SHORT));
246
247 // close interfaces
248 curs->close(&status);
249 curs = NULL;
250
251 tra->commit(&status);
252 tra = NULL;
253
254 att->detach(&status);
255 att = NULL;
256 }
257 catch (const FbException& error)
258 {
259 // handle error
260 rc = 1;
261

Callers

nothing calls this directly

Calls 15

setenvFunction · 0.85
getStatusMethod · 0.45
getDispatcherMethod · 0.45
addRefMethod · 0.45
attachDatabaseMethod · 0.45
startTransactionMethod · 0.45
openCursorMethod · 0.45
fetchNextMethod · 0.45
closeMethod · 0.45
commitMethod · 0.45
detachMethod · 0.45
formatStatusMethod · 0.45

Tested by

no test coverage detected