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

Function main

examples/interfaces/12.batch_isc.cpp:127–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127int main()
128{
129 int rc = 0;
130
131 // set default password if none specified in environment
132 setenv("ISC_USER", "sysdba", 0);
133 setenv("ISC_PASSWORD", "masterkey", 0);
134
135 // With ThrowStatusWrapper passed as status interface FbException will be thrown on error
136 ThrowStatusWrapper status(master->getStatus());
137
138 ISC_STATUS_ARRAY st;
139 isc_db_handle db = 0;
140 isc_tr_handle tr = 0;
141 isc_stmt_handle stmt = 0;
142 isc_blob_handle blb = 0;
143
144 // Declare pointers to required interfaces
145 /*IProvider* prov = master->getDispatcher();
146 IAttachment* att = NULL;*/
147 IUtil* utl = master->getUtilInterface();
148 IStatement* statement = NULL;
149 ITransaction* tra = NULL;
150 IBatch* batch = NULL;
151 IBatchCompletionState* cs = NULL;
152 IXpbBuilder* pb = NULL;
153
154 unsigned char streamBuf[10240]; // big enough for demo
155 unsigned char* stream = NULL;
156
157 try
158 {
159 // attach employee db
160 if (isc_attach_database(st, 0, "employee", &db, 0, NULL))
161 raiseError(status, st);
162
163 isc_tr_handle tr = 0;
164 if (isc_start_transaction(st, &tr, 1, &db, 0, NULL))
165 raiseError(status, st);
166
167 // cleanup
168 const char* cleanSql = "delete from project where proj_id like 'BAT%'";
169 if (isc_dsql_execute_immediate(st, &db, &tr, 0, cleanSql, 3, NULL))
170 raiseError(status, st);
171
172 if (isc_dsql_allocate_statement(st, &db, &stmt))
173 raiseError(status, st);
174
175 // get transaction interface
176 if (fb_get_transaction_interface(st, &tra, &tr))
177 raiseError(status, st);
178
179 //
180 printf("\nPart 1. BLOB created using IBlob interface.\n");
181 //
182
183 // prepare statement
184 const char* sqlStmt1 = "insert into project(proj_id, proj_name) values(?, ?)";

Callers

nothing calls this directly

Calls 15

setenvFunction · 0.85
raiseErrorFunction · 0.70
print_csFunction · 0.70
errPrintFunction · 0.70
getStatusMethod · 0.45
getUtilInterfaceMethod · 0.45
clearMethod · 0.45
getMetadataMethod · 0.45
getXpbBuilderMethod · 0.45
insertIntMethod · 0.45
createBatchMethod · 0.45
getBufferLengthMethod · 0.45

Tested by

no test coverage detected