Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 19
Registered: ‎09-24-2011
My Device: blackberry 8520
My Carrier: MTN
Accepted Solution

SQLite problem

Hi,

 

i'm struggling to execute this kind of sql statement in sqlite with blackberry:

 

SELECT * FROM client WHERE name LIKE '%bla%'

 

the LIKE used with % string % for specifying that you want results with "bla" included in the name doesn't work. can someone help me or give me an alternative?  thx

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: SQLite problem

What actually happen in your application?

 

Do you get any record in the cursor? Do you get any error?

 

It's hard to help if you don't give any detail on the problem...

Contributor
Posts: 19
Registered: ‎09-24-2011
My Device: blackberry 8520
My Carrier: MTN

Re: SQLite problem

my question is to know how to write this kind of statement because i've tried to write them as on mysql, MS sql or oracle but it does not work. is there any particular way to do that with sqlite?
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: SQLite problem

The syntax of the query seems correct.

 

Try quering specific names (without '%') out of the table with and without the LIKE operator and see how it goes.

 

E.

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: SQLite problem

Have a look at the SQLiteDemo application that should have cme with your tooling to get an idea of actually how to include SQLite statements into your program. 

Contributor
Posts: 19
Registered: ‎09-24-2011
My Device: blackberry 8520
My Carrier: MTN

Re: SQLite problem

peter_strange: all sql statement work perfectly except the LIKE used with %% to specify that you need only records containing a certain string in the middle of the text..
Contributor
Posts: 19
Registered: ‎09-24-2011
My Device: blackberry 8520
My Carrier: MTN

Re: SQLite problem

ok let me try.
Contributor
Posts: 19
Registered: ‎09-24-2011
My Device: blackberry 8520
My Carrier: MTN

Re: SQLite problem

Statement statement = _db.createStatement("SELECT * FROM Messages WHERE Message like '%" + Query + "%' AND Category LIKE '%" + Category+ "%' AND Favourite LIKE '%" + Favourite+ "%'");

 This is the solution to my problem... i completly forgot to add it... sorry for the delay

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: SQLite problem

Thank you for doing this.