Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/db.cpp @ 4:fdba695b99f1
More fast ( read from DB ).
Improve the precision of marksheet judgement.
author | pyon@macmini |
---|---|
date | Wed, 11 Sep 2013 19:09:14 +0900 |
parents | c066fde99517 |
children | 76db82822e73 |
comparison
equal
deleted
inserted
replaced
3:1a64119ab257 | 4:fdba695b99f1 |
---|---|
1 // Filename : db.cpp | 1 // Filename : db.cpp |
2 // Last Change: 23-Aug-2013. | 2 // Last Change: 11-Sep-2013. |
3 // | 3 // |
4 | 4 |
5 #include "db.h" | 5 #include "db.h" |
6 #include "wx/wxsqlite3.h" | 6 #include "wx/wxsqlite3.h" |
7 | 7 |
241 cont = dated.GetNext( &ccndir ); | 241 cont = dated.GetNext( &ccndir ); |
242 } | 242 } |
243 ccndb.Close(); | 243 ccndb.Close(); |
244 } | 244 } |
245 | 245 |
246 //********** HHS-DB & CCN-DB **********// | |
246 /* DB整合性チェック */ | 247 /* DB整合性チェック */ |
247 wxArrayString CheckDBs( void ) | 248 wxArrayString CheckDBs( void ) |
248 { | 249 { |
249 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | 250 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); |
250 wxSQLite3Database ccndb; | 251 wxSQLite3Database ccndb; |
267 ccndb.Close(); | 268 ccndb.Close(); |
268 | 269 |
269 return result; | 270 return result; |
270 } | 271 } |
271 | 272 |
273 // 被保険者番号リストから氏名と最新ファイルパスを取得 | |
274 wxArrayString GetHhsInfoAndPathByHhsNoList( wxArrayString hhsno ) | |
275 { | |
276 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | |
277 wxSQLite3Database ccndb; | |
278 ccndb.Open( gszFile ); | |
279 | |
280 wxString sql = wxT( "ATTACH 'db/hhs.db' AS hhs;" ); | |
281 wxSQLite3Statement stmt = ccndb.PrepareStatement( sql ); | |
282 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | |
283 | |
284 wxArrayString result; | |
285 for ( int i = 0; i < hhsno.GetCount(); i++ ) { | |
286 wxString str = hhsno[i]; | |
287 str.Append( wxT("_") ); | |
288 | |
289 sql = wxT( "SELECT name FROM hhs.hhs_master WHERE hhsno = ?;" ); | |
290 stmt = ccndb.PrepareStatement( sql ); | |
291 stmt.Bind( 1, hhsno[i] ); | |
292 q = stmt.ExecuteQuery(); | |
293 if ( !q.IsNull(0) ) { | |
294 while ( q.NextRow() ) { | |
295 str.Append( q.GetString(0) ); | |
296 } | |
297 } | |
298 str.Append( wxT("_") ); | |
299 | |
300 sql = wxT( "SELECT path FROM path WHERE hhsno = ? ORDER BY path DESC LIMIT 1;" ); | |
301 stmt = ccndb.PrepareStatement( sql ); | |
302 stmt.Bind( 1, hhsno[i] ); | |
303 q = stmt.ExecuteQuery(); | |
304 if ( !q.IsNull(0) ) { | |
305 while ( q.NextRow() ) { | |
306 str.Append( q.GetString(0) ); | |
307 } | |
308 } | |
309 | |
310 result.Add( str ); | |
311 } | |
312 stmt.Finalize(); | |
313 ccndb.Close(); | |
314 | |
315 return result; | |
316 } |