Subject | Re: [IBO] View, filter or ... ? |
---|---|
Author | Helen Borrie |
Post date | 2001-03-03T19:54:16Z |
At 06:33 PM 03-03-01 +0200, you wrote:
SQL:
select <fieldlist> from aTable
where month = :inmonth and year = :inyear
Then, when the user selects the month and year,
MyQuery.ParamByName('inMonth').AsInteger := <the selected month>;
MyQuery.ParamByName('inYear').AsInteger := <the selected year>;
An alternative would be to make the SQL
select <fieldlist> from aTable
and then use SQLWhereItems in the OnPrepareSQL event. It seems not to be necessary for your requirements, though, since you always use the same two input columns for your parameters.
Cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>Sorry for the "Subject" of the original mail, I was in a hurry :)You need to use parameters. A view here is unnecessary.
>--
>
>Hi !
>
>I wonder if somebody here on the list has a better idea for the
>following problem I have:
>
>1. I have a table with a "month,year,somedata" fields.
>
>2. When the user starts the program he is asked about the month and
>year he wants to work with and then the whole program only works with
>that "somedata".
>
>3. I've "solved" the problem by creating a view after he selects the
>month and data, something like
>q.sql.text:=Format('
>create view curent_table as select * from table where (month=%d) and (year=%d)',
>[cbMonth.itemindex+1,StrToInt(cbYear.items[cbYear.itemindex])]);q.execute;
>After that in the whole program I'm only reffering to the "curent"
>view. I've done this because I find easier to use "select from
>curent_table ... " than appending to all
>queries something like 'where month=... and year=..." (select from
>table where (condition) AND month=... and year=...".
SQL:
select <fieldlist> from aTable
where month = :inmonth and year = :inyear
Then, when the user selects the month and year,
MyQuery.ParamByName('inMonth').AsInteger := <the selected month>;
MyQuery.ParamByName('inYear').AsInteger := <the selected year>;
An alternative would be to make the SQL
select <fieldlist> from aTable
and then use SQLWhereItems in the OnPrepareSQL event. It seems not to be necessary for your requirements, though, since you always use the same two input columns for your parameters.
>Note: the problem with this is that only one user could use theWhy ?
>database at one time...or more users using only the selected month and
>year. In fact this is way I'm trying to find an alternative :)
>4. There is another way of solving this by using filters, butFilters are necessary only if the user needs to select different sets continuously. It doesn't seem as if this is what you want here.
>it's almost the same as the last statement.
Cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________