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

Function main

examples/interfaces/13.null_pk.cpp:35–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33static IMaster* master = fb_get_master_interface();
34
35int main()
36{
37 int rc = 0;
38
39 // set default password if none specified in environment
40 setenv("ISC_USER", "sysdba", 0);
41 setenv("ISC_PASSWORD", "masterkey", 0);
42
43 // status vector and main dispatcher
44 ThrowStatusWrapper status(master->getStatus());
45 IProvider* prov = master->getDispatcher();
46
47 // declare pointers to required interfaces
48 IAttachment* att = NULL;
49 ITransaction* tra = NULL;
50
51 // Interface executes prepared SQL statement
52 IStatement* stmt = NULL;
53
54 // Interfaces provides access to format of data in messages
55 IMessageMetadata* meta = NULL;
56
57 // Interface makes it possible to change format of data or define it yourself
58 IMetadataBuilder* builder = NULL;
59
60 const char* sqlStr =
61 "Insert into COUNTRY values(?, ?)";
62
63 try
64 {
65 // attach employee db
66 att = prov->attachDatabase(&status, "employee", 0, NULL);
67
68 // start transaction
69 tra = att->startTransaction(&status, 0, NULL);
70
71 // prepare statement
72 stmt = att->prepare(&status, tra, 0, sqlStr, SAMPLES_DIALECT, 0);
73
74 // build metadata
75 meta = stmt->getInputMetadata(&status);
76 builder = meta->getBuilder(&status);
77
78 // set nullability on fields
79 for (unsigned n = 0; n < meta->getCount(&status); ++n)
80 {
81 unsigned t = meta->getType(&status, n);
82 builder->setType(&status, n, t | 1);
83 }
84
85 // IMetadata should be ready
86 meta->release();
87 meta = NULL;
88 meta = builder->getMetadata(&status);
89
90 // no need in builder any more
91 builder->release();
92 builder = NULL;

Callers

nothing calls this directly

Calls 15

setenvFunction · 0.85
getStatusMethod · 0.45
getDispatcherMethod · 0.45
attachDatabaseMethod · 0.45
startTransactionMethod · 0.45
prepareMethod · 0.45
getInputMetadataMethod · 0.45
getBuilderMethod · 0.45
getCountMethod · 0.45
getTypeMethod · 0.45
setTypeMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected