# Search using wildcard character %

**URL:** <https://forum.servoy.com/t/search-using-wildcard-character/7304>\
**Category:** Classic Servoy\
**Created:** [April 4, 2007, 2:14pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304 "2007-04-04T14:14:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BobK](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@BobK](https://forum.servoy.com/u/BobK)\
**Post date:** [April 4, 2007, 2:14pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/1 "2007-04-04T14:14:11Z")

</div>

When I do the following search in the name field on a form:  
A%  
I get all the names that start with A. ![:D]( "Very Happy")  
If I then do search  
B%  
I get ‘no results from search’ ![:(]( "Sad")

At first I thought that this was a DB issue, since these searches work in the demo solutions that came with Servoy. The database I am using is Pervasive version 9.50. I tried the following in the Pervasive.SQL Contorl Center:  
select \* from “Lifil010” where name like ‘A%’  
I got all of the names that start with A.  
select \* from “Lifil010” where name like ‘B%’  
I got all of the names that start with B

Now I don’t know what the problem is.

Additional information:  
If I search for A% and get all of the A names, then do B% and extend the search, I get all of the As and Bs, then do B% and reduce the search, I get just the B names.

Any suggestions would be greatly appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [April 4, 2007, 2:45pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/2 "2007-04-04T14:45:47Z")

</div>

That sounds like a bug…

Maybe you can do an additional test, what happens when you search for ‘ba%’ or ‘bb%’ and maybe ‘%a’ and ‘%b’.

Otherwise I suggest you add it to the issue system.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [April 4, 2007, 2:48pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/3 "2007-04-04T14:48:06Z")

</div>

Hmm. But if it works in the Servoy demo solution, it can’t be a bug, can it?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [April 4, 2007, 2:53pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/4 "2007-04-04T14:53:03Z")

</div>

Hmm, Patrick you are right when the demo is based on the same database.  
Otherwise it looks like a Servoy or driver thing. Which brings me to the next thought.

Do you use the latest driver?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [April 4, 2007, 3:07pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/5 "2007-04-04T15:07:43Z")

</div>

OK. I just tried it here and with my DB there is no problem. What I suggest is that you turn on debugging and have a look at the queries fired. To do this you have to set the value

log4j.logger.com.servoy.j2db.util.Debug=DEBUG

in your servoy.properties file.

I just tested with the CRM and got this result

> 2007-04-04 17:04:47,188 DEBUG [AWT-EventQueue-0] com.servoy.j2db.util.Debug - used sql select companies.company\_id from companies where companies.company\_industry like ? orde  
> r by companies.company\_id questiondata.lenght 1  
> 2007-04-04 17:04:47,194 DEBUG [AWT-EventQueue-0] com.servoy.j2db.util.Debug - questiondata[0]= ‘R%’ ,type: java.lang.String
> 
> 2007-04-04 17:04:57,549 DEBUG [AWT-EventQueue-0] com.servoy.j2db.util.Debug - used sql select companies.company\_id from companies where companies.company\_category like ? orde  
> r by companies.company\_id questiondata.lenght 1  
> 2007-04-04 17:04:57,556 DEBUG [AWT-EventQueue-0] com.servoy.j2db.util.Debug - questiondata[0]= ‘W%’ ,type: java.lang.String

You can see the SQL fired and the arguments of the prepared statement. This should help to find the issue.

---

<div class="post-metadata">

**Author:** ![BobK](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@BobK](https://forum.servoy.com/u/BobK)\
**Post date:** [April 4, 2007, 3:20pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/6 "2007-04-04T15:20:39Z")

</div>

I just tried the same type of searches on another form that reads from a Pervasive DB and it worked. Therefore, the problem must be something with the first form.

I will try with the debugger turned on.

---

<div class="post-metadata">

**Author:** ![BobK](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@BobK](https://forum.servoy.com/u/BobK)\
**Post date:** [April 4, 2007, 5:13pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/7 "2007-04-04T17:13:18Z")

</div>

I have performed some additional testing with the debugger turned on. Attached is the log file.

I was successful in performing the searches on the map\_x field but there is still a problem when performing the searches in the name field. The name field is the PK, would that make a difference?

below are the searches I performed. I am including the time of the tests to make it easier to find in the log.

At 11:31 searched for G% in field map\_x, this was successful.  
At 11:32 searched for H% in field map\_x, this was successful.  
At 11:33 searched for A% in field name, this was successful.  
At 11:34 searched for B% in field name, this failed.  
At 11:35 searched for A% in field name, this was successful.  
At 11:36 searched for AC% in field name, this was successful.  
At 11:37 searched for A% in field name, this was successful.  
At 11:38 searched for B% in field name, this failed.  
At 11:39 searched for B% in field name, this failed.

After each failure, the whole foundset was displayed (A to Z).

I looked at the log, but nothing that look like an error jumped out at me. Maybe someone else will see the problem.

Thanks again.

[servoy\_log\_test.txt](https://forum.servoy.com/uploads/short-url/rhjw6MiePSevcMZv8BJXPjbjICI.txt) (138 KB)

---

<div class="post-metadata">

**Author:** ![BobK](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@BobK](https://forum.servoy.com/u/BobK)\
**Post date:** [April 4, 2007, 5:15pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/8 "2007-04-04T17:15:27Z")

</div>

Woops, I lost track of the time. The time of the tests was 12:31 through 12:39.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [April 4, 2007, 5:46pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/9 "2007-04-04T17:46:28Z")

</div>

As far as I could see there is no problem. At least, Sevoy does everything as it should. The only thing that I saw is that all those columns are char (fixed length filled with blanks) and not varchar columns. Since I never use a char column for anything, I don’t really know how they behave…

---

<div class="post-metadata">

**Author:** ![BobK](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@BobK](https://forum.servoy.com/u/BobK)\
**Post date:** [April 5, 2007, 12:00pm UTC](https://forum.servoy.com/t/search-using-wildcard-character/7304/10 "2007-04-05T12:00:31Z")

</div>

I don’t know what changes I made that would have affected the search, but this seems to be working correctly today.

Thanks for your help Patrick and Marcel
