Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Find a "%" character in a find using like clause

1,614 views
Skip to first unread message

Joseph

unread,
Oct 6, 2008, 1:45:09 PM10/6/08
to
I need to find a character of % in a datawindow find function. The
find is built using a like clause and always appends a % at the end of
the string. Any suggestions? Thx

Example 1

string ls_value = "ABC" + "%"
dw_1.find ("code like" + ls_value,1,dw_1.rowcount())

record is found for code value of "ABCD"


Example 1
string ls_value = "A%BC" + "%"
dw_1.find ("code like" + ls_value,1,dw_1.rowcount())

record is NOT found for code value of "A%BCD"

Ken Balakrishnan

unread,
Oct 6, 2008, 4:40:18 PM10/6/08
to
I'm not sure I totally understand your question, but it sounds like you
might find what you need if you look up the help for "LIKE Operator" (which
will bring up the topic "Relational operators in DataWindow expressions")
and scroll down to the "Escape keyword" section.

HTH,
Ken

"Joseph" <niro...@gmail.com> wrote in message
news:3441e6a2-2de7-4b67...@v28g2000hsv.googlegroups.com...

Jeremy Lakeman

unread,
Oct 6, 2008, 6:38:27 PM10/6/08
to
On Oct 7, 6:40 am, "Ken Balakrishnan" <kNOeSP...@cpsREMOVEME92.com>
wrote:

> I'm not sure I totally understand your question, but it sounds like you
> might find what you need if you look up the help for "LIKE Operator" (which
> will bring up the topic "Relational operators in DataWindow expressions")
> and scroll down to the "Escape keyword" section.
>
> HTH,
> Ken
>
> "Joseph" <niroc...@gmail.com> wrote in message

>
> news:3441e6a2-2de7-4b67...@v28g2000hsv.googlegroups.com...
>
> >I need to find a character of % in a datawindow find function.  The
> > find is built using a like clause and always appends a % at the end of
> > the string.  Any suggestions?  Thx
>
> > Example 1
>
> > string ls_value = "ABC" + "%"
> > dw_1.find ("code like" + ls_value,1,dw_1.rowcount())
>
> > record is found for code value of  "ABCD"
>
> > Example 1
> > string ls_value = "A%BC" + "%"
> > dw_1.find ("code like" + ls_value,1,dw_1.rowcount())
>
> > record is NOT found for code value of "A%BCD"

Or just use the pos function instead.
dw_1.find ("pos(code, '"+ls_value+"')>0",1,dw_1.rowcount())

Joseph

unread,
Oct 7, 2008, 10:15:54 AM10/7/08
to

It looks like there are a limited number of options on how to search
for the value "%" in the FIND datawindow method. (I was hoping for a
special character match routine)
Looking for a solution to this issue about finding a ‘%’ value in a
string in the Find operation:

As you know, the % is a wildcard used for searching patterns within a
string. But what happens if you need to find an actual value of ‘%’
within the string? PowerBuilder Find function(s) works similar to the
of LIKE operator in ansi SQL. Unfortunately, there is no way in
PowerBuilder to use the operator LIKE and a value of ‘%” and a
wildcard all in the same search criteria. In order to look for the
actual value of a character of ‘%”, we need to forgo the LIKE
operator. This leaves with two options:

- USE operator, “=”. The “=” operator acts like an exact match
search. This means in order to find a string like “% - OTHOC”, the
user must type in the Find value field “% - OTHOC” in order to find
the record.
– Second option is to change the LIKE operator to a pattern matching
routine. Pattern matching works similar of having a default wildcard
ALWAYS in the beginning and at the end of the find value. However,
you cannot use the “%” value in a middle of a search and have
searching work as a wildcard. Example: searching for a value of “OT”,
it will find records like “% - OTHOC”, “OTCBNH”, “HGROTVG”, and
“HHHGOT”. Example2: searching for a value of “%”, will find records
like “%- OTHOC”, “OOO%LLL”, and “UIJ%”.

Unless there is a special character matching, I don't see any other
alternative.

Jerry Siegel [TeamSybase]

unread,
Oct 7, 2008, 1:51:59 PM10/7/08
to
Sure there is. As Ken suggested, use the escape argument. When you want % to
be a wildcard, do not use the escape character you have declared. When you
want to search for "%" put the escape character in front of it.
Example: you want to search for "100%" followed by anything
my_column like ~'100|%% escape ~'|~'

"Joseph" <niro...@gmail.com> wrote in message

news:0e969c1e-b1a3-4398...@s50g2000hsb.googlegroups.com...

Message has been deleted
0 new messages