comparison src/util.cpp @ 253:eadffc38ab43

Add support for initial INSERT statements for database creation in schema array.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 08 May 2018 15:00:41 +0300
parents 4d2b37a0acf2
children 0e0ad52994ca
comparison
equal deleted inserted replaced
252:4d2b37a0acf2 253:eadffc38ab43
156 if (!slCheckAndReportSQLError( 156 if (!slCheckAndReportSQLError(
157 sql, tcreate.lastError(), true)) 157 sql, tcreate.lastError(), true))
158 return false; 158 return false;
159 159
160 tcreate.finish(); 160 tcreate.finish();
161
162 // If any inserts are specified, do them
163 for (int n = 0; n < SQL_MAX_SCHEMA_INSERTS; n++)
164 {
165 const QString str = table.inserts[n];
166 if (!str.isEmpty())
167 {
168 QSqlQuery insert(db);
169 sql =
170 QStringLiteral("INSERT INTO %1 VALUES(%2)").
171 arg(table.name).
172 arg(str);
173
174 insert.exec(sql);
175
176 if (!slCheckAndReportSQLError(
177 sql, insert.lastError(), true))
178 return false;
179
180 insert.finish();
181 }
182 }
161 } 183 }
162 } 184 }
163 185
164 return true; 186 return true;
165 } 187 }