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

Function main

examples/api/apifull.c:77–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76
77int main (int argc, char** argv)
78{
79 int query[MAXLEN];
80 XSQLDA * sqlda;
81 char db_name[128];
82
83 if (argc < 2)
84 {
85 printf("Enter the database name: ");
86 gets(db_name);
87 }
88 else
89 {
90 strcpy(db_name, argv[1]);
91 }
92
93 if (isc_attach_database(status, 0, db_name, &db, 0, NULL))
94 {
95 printf("Could not open database %s\n", db_name);
96 ERREXIT(status, 1);
97 }
98
99 /*
100 * Allocate enough space for 20 fields.
101 * If more fields get selected, re-allocate SQLDA later.
102 */
103 sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH (20));
104 sqlda->sqln = 20;
105 sqlda->version = 1;
106
107 /* Allocate a global statement */
108 if (isc_dsql_allocate_statement(status, &db, &stmt))
109 {
110 free (sqlda);
111 ERREXIT(status,1)
112 }
113
114 /*
115 * Process SQL statements.
116 */
117 ret = get_statement((char *) query);
118 /* Use break on error or exit */
119 while (ret != 1)
120 {
121 /* We must pass the address of sqlda, in case it
122 ** gets re-allocated
123 */
124 ret = process_statement(&sqlda,
125 (char *) query);
126 if (ret == 1)
127 break;
128 ret = get_statement((char *) query);
129 }
130
131 free (sqlda);
132 if (trans)
133 if (isc_commit_transaction(status, &trans))
134 {

Callers

nothing calls this directly

Calls 2

getsFunction · 0.85
get_statementFunction · 0.85

Tested by

no test coverage detected