public DataTable getZiyaretsizPlanListe(int Gun) {
sql = " SELECT "
+ " (CASE WHEN ([unite].UniteKod)=150) then UniteAd + ' (' + muaSemtBrick.AltBolgeAd + ') '"
+ " ELSE UniteAd + ' (' + [SemtBrick].AltBolgeAd + ')' END ) AS UniteAd, "
+ " Dr.Sabit, Dr.Unvan + ' ' + Dr.Ad + ' ' + Dr.Soyad AS AdSoyad, ZiyaretEtmemeSebep.Kod"
+ " FROM ((DoktorZiyaretNone INNER JOIN ((( Doktor AS Dr INNER JOIN AltIht ON Dr.Ihtisas = AltIht.UKod) "
+" LEFT JOIN Semt AS MuaSemt ON Dr.Adres3 = MuaSemt.UKod) "
+" LEFT JOIN SemtBrick AS MuaSemtBrick ON MuaSemt.AltBolgeKod = MuaSemtBrick.AltBolgeKod) ON DoktorZiyaretNone.Doktor = Dr.Sabit) "
+" LEFT JOIN ZiyaretEtmemeSebep ON DoktorZiyaretNone.Sebep = ZiyaretEtmemeSebep.Sebep) "
+" INNER JOIN ((unite INNER JOIN Semt ON unite.SemtTek = Semt.UKod) "
+" INNER JOIN SemtBrick ON Semt.AltBolgeKod = SemtBrick.AltBolgeKod) ON DoktorZiyaretNone.Unite = unite.UniteKod "
+" WHERE Dr.Unite <> 200 And DoktorZiyaretNone.DTarih = "+ Gun ;
/*+" UNION "
//+" SELECT Dr.Unite as Unite, " +
+" SELECT "
+" EczAd + '(' + [SemtBrick].[AltBolgeAd] + ')' AS UniteAd, Dr.Sabit, Dr.Unvan + ' ' + Dr.Ad + ' ' + Dr.Soyad AS AdSoyad, ZiyaretEtmemeSebep.Kod"
+" FROM (DoktorZiyaretNone INNER JOIN (((Doktor AS Dr INNER JOIN AltIht ON Dr.Ihtisas = AltIht.UKod) INNER JOIN unite ON Dr.Unite = unite.UniteKod) INNER JOIN (Semt INNER JOIN SemtBrick ON Semt.AltBolgeKod = SemtBrick.AltBolgeKod) ON Dr.Adres3 = Semt.UKod) ON DoktorZiyaretNone.Doktor = Dr.Sabit) LEFT JOIN ZiyaretEtmemeSebep ON DoktorZiyaretNone.Sebep = ZiyaretEtmemeSebep.Sebep"
+" WHERE Dr.Unite = 200 And DoktorZiyaretNone.DTarih = " + Gun ;
+" ORDER BY Dr.Unite ";*/
Log.d("EDK","getZiyaretsizPlanListe SQL:" + sql);
return getResult(sql, true);
}
public DataTable getResult(String sqlText, boolean showError){
DataTable dataTable = new DataTable(context);
Cursor cursor;
try {
cursor = db.rawQuery(sqlText, null);
if (cursor!=null)
{dataTable = new DataTable(context, sqlText);
dataTable.setDataSource(cursor, sqlText);
cursor.close();}
} catch (SQLException e) {
Log.e("LOG ERROR", e.getMessage());
if(showError){
Util.setException(context, e);
e.printStackTrace();
}
}
return dataTable;
}
getZiyaretsizPlanListe で sql を実行すると、LogCat からエラーが発生します
06-24 14:55:47.167: E/SQLiteLog(636): (1) no such column: SemtBrick.AltBolgeAd
06-24 14:55:47.167: E/LOG ERROR(636): no such column: SemtBrick.AltBolgeAd (code 1): ,
while compiling: SELECT (CASE WHEN ([unite].UniteKod=150) then UniteAd +
' (' + muaSemtBrick.AltBolgeAd + ') ' ELSE UniteAd + ' (' + [SemtBrick].AltBolgeAd + ')' END ) AS UniteAd,
Dr.Sabit, Dr.Unvan + ' ' + Dr.Ad + ' ' + Dr.Soyad AS AdSoyad, ZiyaretEtmemeSebep.Kod FROM
((DoktorZiyaretNone INNER JOIN ((( Doktor AS Dr INNER JOIN AltIht ON Dr.Ihtisas = AltIht.UKod)
LEFT JOIN Semt AS MuaSemt ON Dr.Adres3 = MuaSemt.UKod) LEFT JOIN SemtBrick AS MuaSemtBrick ON MuaSemt.AltBolgeKod = MuaSemtBrick.AltBolgeKod) ON DoktorZiyaretNone.Doktor = Dr.Sabit)
LEFT JOIN ZiyaretEtmemeSebep ON DoktorZiyaretNone.Sebep = ZiyaretEtmemeSebep.Sebep) INNER JOIN ((unite INNER JOIN Semt ON unite.SemtTek = Semt.UKod)
INNER JOIN SemtBrick ON Semt.AltBolgeKod = SemtBrick.AltBolgeKod) ON DoktorZiyaretNone.Unite = unite.UniteKod WHERE Dr.Unite <> 200 And DoktorZiyaretNone.DTarih = 41449
06-24 14:55:47.187: W/System.err(636): android.database.sqlite.SQLiteException: no such column: SemtBrick.AltBolgeAd (code 1): ,
06-24 14:55:47.187: W/System.err(636): android.database.sqlite.SQLiteException: no such column: SemtBrick.AltBolgeAd (code 1): , while compiling: SELECT (CASE WHEN ([unite].UniteKod=150) then UniteAd + ' (' + muaSemtBrick.AltBolgeAd + ') ' ELSE UniteAd + ' (' + [SemtBrick].AltBolgeAd + ')' END ) AS UniteAd, Dr.Sabit, Dr.Unvan + ' ' + Dr.Ad + ' ' + Dr.Soyad AS AdSoyad, ZiyaretEtmemeSebep.Kod FROM ((DoktorZiyaretNone INNER JOIN ((( Doktor AS Dr INNER JOIN AltIht ON Dr.Ihtisas = AltIht.UKod) LEFT JOIN Semt AS MuaSemt ON Dr.Adres3 = MuaSemt.UKod) LEFT JOIN SemtBrick AS MuaSemtBrick ON MuaSemt.AltBolgeKod = MuaSemtBrick.AltBolgeKod) ON DoktorZiyaretNone.Doktor = Dr.Sabit) LEFT JOIN ZiyaretEtmemeSebep ON DoktorZiyaretNone.Sebep = ZiyaretEtmemeSebep.Sebep) INNER JOIN ((unite INNER JOIN Semt ON unite.SemtTek = Semt.UKod) INNER JOIN SemtBrick ON Semt.AltBolgeKod = SemtBrick.AltBolgeKod) ON DoktorZiyaretNone.Unite = unite.UniteKod WHERE Dr.Unite <> 200 And DoktorZiyaretNone.DTarih = 41449
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
06-24 14:55:47.199: W/System.err(636): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
06-24 14:55:47.199: W/System.err(636): at BusinessObjects.GenelSql.getResult(GenelSql.java:88)
私を助けてください