-4
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;
        }

when i execute sql in getZiyaretsizPlanListe i get error from 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)

Please help me

4

1 回答 1

0

您正在关闭多余的一个括号:

(CASE  WHEN ([unite].UniteKod)=150)

应该

(CASE  WHEN ([unite].UniteKod)=150

同样在您的 From 部分中,您还有一个多余的左括号。
您得到的错误(没有这样的列:SemtBrick.AltBolgeAd)应该在此之后更正,前提是该列存在。

这对你有用吗:

        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 ON DoktorZiyaretNone.Doktor = Dr.Sabit " 
            + " 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 " 
            + " LEFT JOIN ZiyaretEtmemeSebep ON DoktorZiyaretNone.Sebep = ZiyaretEtmemeSebep.Sebep "
            + " INNER JOIN unite ON DoktorZiyaretNone.Unite = unite.UniteKod "
            + " INNER JOIN Semt ON unite.SemtTek = Semt.UKod "
            + " INNER JOIN SemtBrick ON Semt.AltBolgeKod = SemtBrick.AltBolgeKod "
            + " WHERE Dr.Unite <> 200 And DoktorZiyaretNone.DTarih = " + Gun ;
于 2013-06-24T12:06:35.657 回答