Welcome Guest  |  Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 3
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1225 times and has 2 replies Next Thread
Male farble1670
Novice
Member's Avatar

USA
Joined: Feb 24, 2005
Post Count: 40
Status: Offline
Reply to this Post  Reply with Quote 
matches() not correctly form LIKE stmt

if i do:

matches("c*")


the SQL i see is:

... LIKE ? ESCAPE '\' OR THIS.DESCRIPTION LIKE ? ESCAPE '\' :End prepared statement with 2 parameters begin parameter #1: c* :end parameter begin parameter #2: c*


shouldn't the parameters have been: c%? note that if i do:

matches("c.*")


the SQL is (correctly):

... LIKE ? ESCAPE '\' OR THIS.DESCRIPTION LIKE ? ESCAPE '\' :End prepared statement with 2 parameters begin parameter #1: c% :end parameter begin parameter #2: c% :end parameter


?

thanks.
----------------------------------------
--
jtb
[Aug 22, 2006 10:51:20 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 2991
Status: Offline
Reply to this Post  Reply with Quote 
Re: matches() not correctly form LIKE stmt

I dont think it's possible to translate c* into SQL LIKE pattern.

System.out.println("aaaaaac".matches("a*c")); //true
System.out.println("aaaaaac".matches("a.*c")); //true
System.out.println("adddddc".matches("a*c")); //false
System.out.println("adddddc".matches("a.*c")); //true

You can raise a bug
----------------------------------------
Erik Bengtson


[Aug 23, 2006 7:26:05 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male farble1670
Novice
Member's Avatar

USA
Joined: Feb 24, 2005
Post Count: 40
Status: Offline
Reply to this Post  Reply with Quote 
Re: matches() not correctly form LIKE stmt

hi eric, thanks.

the spec says:

applies to String type; only the following regular expression
patterns are required to be supported and are portable: global
“(?i)” for case-insensitive matches; and “.” and “.*” for
wild card matches. The pattern passed to matches must be a
literal or parameter.


so it sounds like this is not a bug ... that it is user error :)
----------------------------------------
--
jtb
[Aug 23, 2006 4:46:44 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread