Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Like operator in a filter datawindow expression

4 posts in General Discussion Last posting was on 2000-06-29 15:38:14Z
François Jamin Posted on 2000-06-29 12:57:17Z
Newsgroups: sybase.public.powerbuilder.general
From: "François Jamin" <fjamin@ctp.com>
Subject: Like operator in a filter datawindow expression
X-Newsreader: Microsoft Internet News 4.70.1162
Date: Thu, 29 Jun 2000 08:57:17 -0400
Lines: 15
NNTP-Posting-Host: vevfir01.nestec.ch 141.122.72.81
Message-ID: <385_01bfe1c8$48e2dfc0$23417a8d@chvev2301.nestec.ch>
Path: forums-1-dub!forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.powerbuilder.general:78570
Article PK: 531074

Hi,

We are using the like operator for searching in a datawindow column
depending of the value of a string entered by the user.

The problem is that if the user wants to search for a value containing
PRODUCT%' ( the '%' is a character not the wildcard ) the filter returns
no rows but some values are 'PRODUCT% 12' or 'PRODUCT% 11' and should be
returned.

We add always a '%' add the end so the like expression is 'PRODUCT%%'.

The question is how to search for the characters '%' or '_' in a string ?

Thanks for your reply.

françois


madhu Bharadwaj Posted on 2000-06-29 15:38:14Z
Newsgroups: sybase.public.powerbuilder.general
Date: Thu, 29 Jun 2000 10:38:14 -0500
From: madhu Bharadwaj <msbharadwaj@mmm.com>
X-Mailer: Mozilla 4.5 [en]C-CCK-MCD 3M/NCP 4.5 (WinNT; I)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Re: Like operator - sorry misread question
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Lines: 17
NNTP-Posting-Host: 169.10.116.232
Message-ID: <385_395B6D65.40A35E23@mmm.com>
References: <385_01bfe1c8$48e2dfc0$23417a8d@chvev2301.nestec.ch>
Path: forums-1-dub!forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.powerbuilder.general:78551
Article PK: 531056

Sorry for misreading the question.

madhu

"François Jamin" wrote:

> Hi,
>
> We are using the like operator for searching in a datawindow column
> depending of the value of a string entered by the user.
>
> The problem is that if the user wants to search for a value containing
> PRODUCT%' ( the '%' is a character not the wildcard ) the filter returns
> no rows but some values are 'PRODUCT% 12' or 'PRODUCT% 11' and should be
> returned.
>
> We add always a '%' add the end so the like expression is 'PRODUCT%%'.
>
> The question is how to search for the characters '%' or '_' in a string ?
>
> Thanks for your reply.
>
> françois


madhu Bharadwaj Posted on 2000-06-29 14:20:30Z
Newsgroups: sybase.public.powerbuilder.general
Date: Thu, 29 Jun 2000 09:20:30 -0500
From: madhu Bharadwaj <msbharadwaj@mmm.com>
X-Mailer: Mozilla 4.5 [en]C-CCK-MCD 3M/NCP 4.5 (WinNT; I)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Re: Like operator in a filter datawindow expression
Content-Type: multipart/alternative; boundary="------------15986D74A4353CB5F2604061"
Lines: 51
NNTP-Posting-Host: 169.10.116.232
Message-ID: <385_395B5B2E.6417DCFE@mmm.com>
References: <385_01bfe1c8$48e2dfc0$23417a8d@chvev2301.nestec.ch>
Path: forums-1-dub!forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.powerbuilder.general:78564
Article PK: 531070

The escape character is  square brackets [] to escape a wildcard.
 
Try :
           where rowname like "Product[%]%"
 

madhu
"François Jamin" wrote:

Hi,

We are using the like operator for searching in a datawindow column
depending of the value of a string entered by the user.

The problem is that if the user wants to search for a value containing
PRODUCT%' ( the '%' is a character not the wildcard )  the filter returns
no rows but some values are 'PRODUCT% 12' or 'PRODUCT% 11' and should be
returned.

We add always a '%' add the end  so the like expression is 'PRODUCT%%'.

The question is how to search for the characters '%' or '_' in a string ?

Thanks for your reply.

françois


Stephen Barrett Posted on 2000-06-29 15:26:46Z
Newsgroups: sybase.public.powerbuilder.general
From: "Stephen Barrett" <stephen_barrett@aoncons.com>
Subject: Re: Like operator in a filter datawindow expression
Date: Thu, 29 Jun 2000 11:26:46 -0400
Lines: 110
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_NextPart_000_009A_01BFE1BC.E9001060"
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
NNTP-Posting-Host: n0-45.aon.com 199.245.0.45
Message-ID: <385_LLHDD$d4$GA.288@forums.sybase.com>
References: <385_01bfe1c8$48e2dfc0$23417a8d@chvev2301.nestec.ch> <385_395B5B2E.6417DCFE@mmm.com>
Path: forums-1-dub!forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.powerbuilder.general:78554
Article PK: 531059

Just a follow up.  We had to do the same thing and we did basically what madhu suggested.  We added code to SQLPreview event in datawindow to look for all the %'s except the lastone and wrap it with [].  This assumes that the user will not enter a % to mean a wildcard character.  If they do, you cannot distinguish between a literal % or a wildcard %.  In this case, you leave the logic up to the user ( couldn't do that here) when to put literals and when to put wildcards.
"madhu Bharadwaj" <msbharadwaj@mmm.com> wrote in message news:395B5B2E.6417DCFE@mmm.com...
The escape character is  square brackets [] to escape a wildcard.
 
Try :
           where rowname like "Product[%]%"
 

madhu
"François Jamin" wrote:

Hi,

We are using the like operator for searching in a datawindow column
depending of the value of a string entered by the user.

The problem is that if the user wants to search for a value containing
PRODUCT%' ( the '%' is a character not the wildcard )  the filter returns
no rows but some values are 'PRODUCT% 12' or 'PRODUCT% 11' and should be
returned.

We add always a '%' add the end  so the like expression is 'PRODUCT%%'.

The question is how to search for the characters '%' or '_' in a string ?

Thanks for your reply.

françois