2013-04-09 3 views
0

안녕하세요, 아래에이 쿼리를 구현했습니다. 언급이 있습니다.Sql 쿼리가 지원되지 않습니다. android의 이전 버전

이 쿼리의 목적은 저장된 로컬 데이터베이스에있는 두 개의 열을 내가 보낸 금액입니다. 그 금액에 대한 배달 요금은 얻을 수 있습니다.하지만 이전 버전의 첫 번째 값만 가져 오지만 새 버전이 성공적으로 업데이트됩니다. 왜 이전 버전이 업데이트인지 모릅니다.

검색어 :

mCursor = db.rawQuery("select ROUND(deliverycharge) from pincodedetails where ROUND(subtotal) <=(select ROUND(subtotal) from pincodedetails where ROUND(subtotal)>="+price+" and resturantID="+selArgs+" LIMIT 1) and resturantID="+selArgs+" and ROUND(subtotal) >=(select ROUND(subtotal) from pincodedetails where ROUND(subtotal)<="+price+" and resturantID="+selArgs+" LIMIT 1) order by ROUND(subtotal) LIMIT 1", null); 

내가 LIMIT 1 이전 버전에서 지원되지 않습니다 생각합니다.

나에게 해결책을 알려주시겠습니까?

public double getAllPincodeDetails(
      String dinein_restaurant_id,Double GetAllPrice) { 
     // TODO Auto-generated method stub 
     String selArgs = dinein_restaurant_id; 
     Double price = GetAllPrice; 
     String query = "select ROUND(delivarycharge) from pincodedetails where ROUND(subtotal) <=(select ROUND(subtotal) from pincodedetails where ROUND(subtotal)>="+price+" and resturantID="+selArgs+" LIMIT 1) and resturantID="+selArgs+" and ROUND(subtotal) >=(select ROUND(subtotal) from pincodedetails where ROUND(subtotal)<="+price+" and resturantID="+selArgs+" LIMIT 1) order by ROUND(subtotal) LIMIT 1"; 
     Log.i(this.toString(), "Message"+query); 
     mCursor = db.rawQuery("select ROUND(delivarycharge) from pincodedetails where ROUND(subtotal) <=(select ROUND(subtotal) from pincodedetails where ROUND(subtotal)>="+price+" and resturantID="+selArgs+" LIMIT 1) and resturantID="+selArgs+" and ROUND(subtotal) >=(select ROUND(subtotal) from pincodedetails where ROUND(subtotal)<="+price+" and resturantID="+selArgs+" LIMIT 1) order by ROUND(subtotal) LIMIT 1", null); 
     double delivarycharge = 0; 
     if (mCursor.moveToFirst()) 
     { 
      // Got first result 
      delivarycharge = mCursor.getDouble(0); 
     //System.out.println("***************"+mCursor.getString(mCursor.getColumnIndex("totamount")));System.out.println("***************"+mCursor.getString(mCursor.getColumnIndex("price"))); 
     } 
// 
     return delivarycharge; 
    } 
+0

정확히 어떤 버전의 Android? 및 API? –

+0

2.2 버전 및 API 8 – Gomathi

+0

dubug를 실행하는 동안 문자열 쿼리가 발생했습니다. 복사 한 Sqllite 데이터베이스 소프트웨어가 해당 쿼리에 넣었습니다. 모든 버전에서 결과가 완벽하게 나타납니다.하지만 새 버전에서는 에뮬레이터를 사용할 수 없습니다. – Gomathi

답변

0

SQlite는 제한된 SQL 구현이며 ... 더 큰 DBMS와는 다른 목적으로 설계되었습니다.

SELECT 쿼리를 단순화하고 Java 코드에서 일부 처리를 수행해야합니다.

여기를 참조하십시오. SQL Lite Documentation

관련 문제