CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> General/Other

 SQL headache.

Print topic Send  topic

Author Message
Mac

Posts: 37
Posted: 07/29/2005, 7:01 PM

Hi folks, I'm hoping you can help me out here, kinda new to codecharge and having a few teething problems ;)

I have a grid that is fed by a search that was created with the grid builder, this works fine.

The problem is I need to only have a subset of data sent to this grid, basically all records in the database set with a certain flag should only ever be searchable, but currently I get the entire database to search upon.

I have tried adding a line to the SQL statements in the datasource for the grid that aleady contains the SQL to resolve the search but I can't seem to work out the correct way to do this.

Any help here would be great.

Thanks in advance.
_________________
/\/\@<
View profile  Send private message
wkempees
Posted: 07/30/2005, 4:11 AM

Your Search From leads to a Grid, the Search works, resulting in a Grid
displaying the records that confirm to the Search criteria, probably as
generated.
But, you have an extra filtering option you would like to apply thereby
narrowing the result set.

In the Properties of your Grid, Datasource [...] click the [...] button.
This will bring you to the definition of your SQL statement.
Look at the Where part of the Data Source.
Add a line by pressing the '+' sign and enter any valid expression.
Mind the 'And' and 'Or', Parameter and Expression possibilities.
This will prove to be easy.

Hope this helps.
Greetz Walter
Mac

Posts: 37
Posted: 07/30/2005, 5:58 AM

Yep this is what I have been trying to do.

The problem is the SQL generated for the search has 4-5 criteria that are OR and I need to add the additional filter of only displaying succesfull search results that also have a certain value in a non-search field. So I am having problems working out where to put the x = y statement.
_________________
/\/\@<
View profile  Send private message
donb

Posts: 52
Posted: 07/30/2005, 7:36 AM

You want the where parameter to be like
a=x AND
(b={param1} OR
c={param2} OR
d={param3})

Note the use of parentheses
_________________
http://www.gotodon.com/ccbth
View profile  Send private message
Mac

Posts: 37
Posted: 07/30/2005, 7:57 AM

Thanks I actually cracked the problem myself a few minutes before your reply and yes it works almost as I wish.

I have only two small problems.

Firstly the only way I could find to add a literal x = y statement was to create a hidden field and set it's default value to the string I wish to filter on, I then add a datafield = hiddenfield expression, I would much rather have used a string constant as this filter will never change for this page, but only a small gripe.

My major headache now is that when the page is first loaded the whoel database is still displayed in the grid until the search button is clicked for the first time and filters the records.

Is there a way to get the search to happen on page load to set the filter for the grid?

Probably seeing it in action would be better so here is a URL

http://www.mystical.darktech.org/ccladmin/test.php

If you click search without any keyword you will see the result I would prefer to have on page load.

Thanks.
_________________
/\/\@<
View profile  Send private message
wkempees
Posted: 07/30/2005, 5:28 PM

Get an aspirine and throw it away, cause you almost solved it.
Do mine and DonB's combined.
In the Datasource get the where clause to do everything you want
by putting all the 'static' where clauses first
forget about the s_keyword bit, and make it work.
everything between ().
If it does what you want then add the s_keyword in an 'and' outside the
brackets.
This should get you a good nights rest.
And as always, if it seems impossible then you're trying too hard.

Night night, Walter 02.28 AM GMT Yawn
donb

Posts: 52
Posted: 07/30/2005, 6:01 PM

Tbis is a good place to toss in a mention of the two types of where parameters - "Parameter" and "Expression.

Parameter type Wheres let you specify a column, relational operator, and a source value. This might confuse people because Expression is a Parameter Source.

Expression type Wheres let you specify a piece of "where clause" to be directly inserted into the query.

Why the two, you ask? Because sometimes you want to 'hardwire' a where term, such as "WHERE someflag = 1" .

So, you can add Parameter type where clauses to collect data from various places in your application, or add an Expression type where clause to stuff fixed values into the where clause.

You initially described what I would have defined as an Expression Where clause.

A subtle but important point: The Expression gets evaluated by the database, while the Parameter gets evaluated by the script engine (ASP, PHP, etc.) before it's sent to the database.
_________________
http://www.gotodon.com/ccbth
View profile  Send private message
Mac

Posts: 37
Posted: 07/30/2005, 11:13 PM

Thanks guys, it makes a lot more sense now and the difference between paramater and expression is now aparant after a nit of playing around.

I havn't touched any kind of coding for about 10 years although prior to that I spent 9 years as an IBM mid-range programmer (RPG & RPGII) so I'm not exactly dumb to the basic concepts of this.

This is pretty much my first attempt at anything clever with websites, but codecharge is removing a lot of the work load, I only purchased it 2 days ago and I think it's already saved me a good few weeks work!

Here is the URL to the test server for my first day of build, I'm quite proud of it :) now I can get some sleep and crack on tomorrow. Thanks for your help.

http://www.mystical.darktech.org/ccladmin/registrations.php
_________________
/\/\@<
View profile  Send private message
wkempees
Posted: 07/31/2005, 3:11 AM

Wow!
peterr


Posts: 5971
Posted: 07/31/2005, 1:22 PM

Great work for 1 day indeed.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Walter Kempees
Posted: 08/01/2005, 4:57 AM

Peterr: My thoughts exactly.
"peterr" <peterr@forum.codecharge> schreef in bericht
news:242ed331f7e4b0@news.codecharge.com...
> Great work for 1 day indeed.
> _________________
> Peter R.
> YesSoftware Forums Moderator
> For product support please visit http://support.yessoftware.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


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

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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