CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Problem Integrating Searches into SQL statement

Print topic Send  topic

Author Message
TonyE
Posted: 08/21/2002, 8:54 AM

My SQL statement is as following

SELECT parts.*, SUM(price*price_factor) AS net_price
FROM parts, companies
Where company_id = {CompID} AND item_id LIKE '%{s_item_id}%' AND
description LIKE '%{s_description}%'
Group By item_id

I added the following input parameters in my SQL statement.

Variable Type Input Parameter Type Default

CompID Integer CompID Session 0
s_description text s_description URL
s_item_id text s_item_id URL


Problem
The search function basically works, except if my search criteria is empty then nothing gets displayed in my grid.

How do I add placeholders or change the SQL statement, to make everything appear if the search form is empty.

Thanks for your help

Tony
Nicole
Posted: 08/22/2002, 5:54 AM

Tony,
it happens because no search parameters are passed the default values of sql parameters are used. In your case:
Where company_id = 0 AND item_id LIKE '%%' AND
description LIKE '%%'

I suppose there're no records witch match such condition. The workaround is to cut Where clause from generated SQL in form Before Execute Select. To access SQL and CountSQL variables use code like below (PHP)
global $form_name;
echo $form_name->ds->SQL;
echo $form_name->ds->CountSQL;
TonyE
Posted: 08/22/2002, 8:20 AM

Thanks Nicole
I just figured out the easiest way around it.


I needed to add by the input parameters source for s_description and s_item_id '%' as default paramter.

I did try % as placeholder before, but I never enclosed it with the ' symbol
(The % is a placeholder for every letter or number) So everything will match even an empty field.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.