BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Filter Question ?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop)
View previous topic :: View next topic  
Author Message
Sasan
Guest





PostPosted: Thu Apr 22, 2004 9:26 pm    Post subject: Filter Question ? Reply with quote



Hi,
I select records of Table in a range
that no way to select that:

Table->Filter = "ID = 3 or ID = 56 or ID = ..."

I tested it work but i don't no if number of records
be over than 100,000 but this way work ?

If any way is to select record tell me,
to use filter i have ID that not arranged.


Thanks M.T



Back to top
Jayme Jeffman Filho
Guest





PostPosted: Fri Apr 23, 2004 12:15 am    Post subject: Re: Filter Question ? Reply with quote



Hello,

Do you have a rule to get the id's ? If so you can use a TQuery component .

HTH

Jayme.

"Sasan" <sasan_vm (AT) yahoo (DOT) com> wrote

Quote:
Hi,
I select records of Table in a range
that no way to select that:

Table->Filter = "ID = 3 or ID = 56 or ID = ..."

I tested it work but i don't no if number of records
be over than 100,000 but this way work ?

If any way is to select record tell me,
to use filter i have ID that not arranged.


Thanks M.T





Back to top
Dwayne
Guest





PostPosted: Tue Apr 27, 2004 6:11 pm    Post subject: Re: Filter Question ? Reply with quote



Hello Sasan,

I select records of Table in a range
that no way to select that:

Table->Filter = "ID = 3 or ID = 56 or ID = ..."

I tested it work but i don't no if number of records
be over than 100,000 but this way work ?

If any way is to select record tell me,
to use filter i have ID that not arranged.

I think I may undestand what you are asking... Please forgive me
if I am wrong...

You want a "Range of Records" from one to another. Or be able to
call a certain record up.

To Select a Range you do the following.

Table1->SetRangeStart(); // Set the beginning key
Table1->FieldByName("ID")->AsString = " 3";
Table1->SetRangeEnd(); // Set the ending key
Table1->FieldByName("ID")->AsString = "99";
Table1->ApplyRange(); // Apply the Range!

This will select *all* the ID's between these two numbers...3 and
99.

If you want only a Specific ID..

Table1->FieldByName("ID")="99"
if(Table1->GotoKey()!=0)
{
printf "Record ID not found!"
}

Dwayne


Back to top
Sasan
Guest





PostPosted: Thu Apr 29, 2004 6:15 pm    Post subject: Re: Filter Question ? Reply with quote

Hi Dwayne,
I want filter over than 100,000 record
that i no way for set a range, thats ID test in another
Table then select , now how can filter selected ID's

Filter = ID = 5 or ID = 98,,,

thats work but may be i have a problem on huge Table.

M.T




Back to top
Jayme Jeffman Filho
Guest





PostPosted: Thu Apr 29, 2004 6:58 pm    Post subject: Re: Filter Question ? Reply with quote

Hello Sasan,

Let's explore the question a little bit. How do you know the ID's you want to get ? Is there any other attribute in the table that suport your decision ? Is the condition in another table ? If you don't mind would you please give us more details on how have you found you need to filter the table on the "5" and "98" ID number .

Jayme.


"Sasan" <sasan_vm (AT) yahoo (DOT) com> wrote

Quote:
Hi Dwayne,
I want filter over than 100,000 record
that i no way for set a range, thats ID test in another
Table then select , now how can filter selected ID's

Filter = ID = 5 or ID = 98,,,

thats work but may be i have a problem on huge Table.

M.T






Back to top
Sasan
Guest





PostPosted: Thu Apr 29, 2004 9:25 pm    Post subject: Re: Filter Question ? Reply with quote

Hi Jayme Jeffman Filho

I have two Table

TableId : [ID] is Key
TableCode : [ID,CODE] is Key

i select records from TableCode for example
CODE = 25

then i have many record in TableCode with difrent ID,
and must select this ID's from TableId.

ID = 5 or ID = 98 ,,,

now wrote filter with :
Filter = ,,,

but i wana best way to select ID's ?

Thanks M.T


Back to top
Sasan
Guest





PostPosted: Thu Apr 29, 2004 9:27 pm    Post subject: Re: Filter Question ? Reply with quote

Hi Jayme Jeffman Filho

I have two Table

TableId : [ID] is Key
TableCode : [ID,CODE] is Key

i select records from TableCode for example
CODE = 25

then i have many record in TableCode with difrent ID,
and must select this ID's from TableId.

ID = 5 or ID = 98 ,,,

now wrote filter with :
Filter = ,,,

but i wana best way to select ID's ?

Thanks M.T




Back to top
Dwayne
Guest





PostPosted: Fri Apr 30, 2004 12:35 am    Post subject: Re: Filter Question ? Reply with quote

Susan>>
Hi Dwayne,
I want filter over than 100,000 record
that i no way for set a range, thats ID test in another
Table then select , now how can filter selected ID's

Filter = ID = 5 or ID = 98,,,

thats work but may be i have a problem on huge Table.
<<

Ok, then another way how to do it, is to make a secondary index on
the field that you want.
That way you do not have to "Filter" the Dbase, and the lookup will be
extremely fast. But you have to
write your own limitation code. (Which is not too hard, i gave a extremely
simplifited Psuedo code for you on two buttons).





Table1->SetKey();
Table1->FieldByName("ID")=FirstIDYouWant.;
Table1->GotoNearest(); (in case the record doesn't exist yet, go to
nearest record to it)


Then make your own "<" and ">" commands.

if Button1(the button with ">" on it) is pressed
{
Table1->Next();
if(Table1->FieldByName(ID)>LastIDYouWant) && (!Table1->Eof)
{
Table1->Previous();
}
}

if Button2(the button with "<" on it) is pressed
{
Table1->Previous();
if(Table1->FieldByName(ID)<LastIDYouWant) && (!Table1->Bof)
{
Table1->Next();
}

}



If possible, can you give example of what you want done? That
way we can understand fully what you want to accomplish.

Dwayne


Back to top
Jayme Jeffman Filho
Guest





PostPosted: Fri Apr 30, 2004 1:02 pm    Post subject: Re: Filter Question ? Reply with quote

Hello Sasan,

Now the problem has a better solution. You have two ways, one using two TTable components plus a TDataSource and other using a single TQuery component.

The first one:
====================================
// Setting up parameters before opening the DataSet
Table1->Close();
Table2->Close();
Table1->TableName = "TableCode" ;
DataSource1->DataSet = Table1;
Table2->TableName = "TableID" ;
Table2->MasterSource = DataSource1;
Table2->MasterFields = "ID";

// Setting up the filter condition ( it could be done any where in the code ) after having set up the components
Table1->Filtered = false;
Table1->Filter = "CODE = 25";
Table1->Filtered = true;
if(!Table1->Active) Table1->Open();
if(!Table2->Active) Table2->Open();
// At this point the Table2 DataSet only has records which ID corresponds to a Code 25
......
###########################################

The second one:
======================================
// Setting up TQuery component with a inner join SQL command
Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Add("SELECT t2.id");
Query1->SQL->Add("FROM TableCode t1, TableID t2");
Query1->SQL->Add("WHERE t1.code = :ncode");
Query1->SQL->Add("AND t2.id = t1.id");
if(!Query1->Prepared) Query1->Prepare();
Query1->ParamByName("ncode")->ParamType = ptInput;
Query1->ParamByName("ncode")->DataType = ftInteger;
Query1->ParamByName("ncode")->AsInteger = 25;
Query1->Open();
// At this point all the records in Query1 corresponds to a Code = 25
.....
##########################################

HTH

Jayme.


"Sasan" <sasan_vm (AT) yahoo (DOT) com> wrote

Quote:
Hi Jayme Jeffman Filho

I have two Table

TableId : [ID] is Key
TableCode : [ID,CODE] is Key

i select records from TableCode for example
CODE = 25

then i have many record in TableCode with difrent ID,
and must select this ID's from TableId.

ID = 5 or ID = 98 ,,,

now wrote filter with :
Filter = ,,,

but i wana best way to select ID's ?

Thanks M.T




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.