Saturday, October 15, 2011

Re: [android-developers] android.database.sqlite.SQLiteException: near "*": syntax error: , while compiling: SELECT calls._id as _id, number, name, date, duration, new, type FROM calls LEFT OUTER JOIN blur_calls_name_type ON (blur_calls_name_type._id

If you use concatenation, you need to quote and escape your strings.
If you use query parameters (? in your WHERE clause and a String[]
where you have the null), you do not need to quote or escape your
strings.

On Fri, Oct 14, 2011 at 5:28 AM, vinay kumar mj <vinay.android@gmail.com> wrote:
> Hi
>
> I want to query the call log details from phone, my query is like
> below
>
> Cursor groupCur =
> mcontext.getContentResolver().query(Calls.CONTENT_URI,
>                                CallLogAdapter.PROJECTION, Calls.NUMBER + " = " + number, null,
>                                Calls.DEFAULT_SORT_ORDER);
>
> CallLogAdapter.PROJECTION contain some fields(columns) of call log.
>
> It works fine, but in below condition it will give force close.
> Condition:-If dial number starting with * or # (ex: *1234567 or
> #123457) and number end with *  (ex: 1234567*)
>
> ERROR LOG:
>
> 10-14 14:54:50.425: INFO/Database(26307): sqlite returned: error code
> = 1, msg = near "*": syntax error
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): Writing exception to
> parcel
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):
> android.database.sqlite.SQLiteException: near "*": syntax error: ,
> while compiling: SELECT _id, number, name, date, duration, new, type
> FROM calls WHERE (number = *674088888) ORDER BY date DESC
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.database.sqlite.SQLiteCompiledSql.native_compile(Native
> Method)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:
> 92)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:
> 65)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:
> 42)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:
> 1356)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:
> 330)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> com.android.providers.contacts.CallLogProvider.query(CallLogProvider.java:
> 129)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.content.ContentProvider
> $Transport.bulkQuery(ContentProvider.java:174)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.content.ContentProviderNative.onTransact(ContentProviderNative.java:
> 111)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> android.os.Binder.execTransact(Binder.java:320)
> 10-14 14:54:50.429: ERROR/DatabaseUtils(26307):     at
> dalvik.system.NativeStart.run(Native Method)
> 10-14 14:54:50.429: DEBUG/AndroidRuntime(27470): Shutting down VM
> 10-14 14:54:50.429: WARN/dalvikvm(27470): threadid=1: thread exiting
> with uncaught exception (group=0x40015560)
> 10-14 14:54:50.433: ERROR/AndroidRuntime(27470): FATAL EXCEPTION: main
> 10-14 14:54:50.433: ERROR/AndroidRuntime(27470):
> android.database.sqlite.SQLiteException: near "*": syntax error: ,
> while compiling: SELECT _id, number, name, date, duration, new, type
> FROM calls WHERE (number = *674088888) ORDER BY date DESC
> 10-14 14:54:50.433: ERROR/AndroidRuntime(27470):     at
> android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:
> 158)
> 10-14 14:54:50.433: ERROR/AndroidRuntime(27470):     at
> android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:
> 114)
> 10-14 14:54:50.433: ERROR/AndroidRuntime(27470):     at
> android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:
> 330)
> 10-14 14:54:50.433: ERROR/AndroidRuntime(27470):     at
> android.content.ContentProviderProxy.query(ContentProviderNative.java:
> 366)
> 10-14 14:54:50.433: ERROR/AndroidRuntime(27470):     at
> android.content.ContentResolver.query(ContentResolver.java:262)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_ Version 2.0
Available!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate