filter or where statement in SQL

filter or where statement in SQL

Postby Horizon » Wed May 06, 2020 11:21 am

Hi Mr. Rao,

I want to clarify my mind.

We can create rowset without any sql statement and next set filter.
Code: Select all  Expand view
oRs:=oCn:RowSet('bigdata')
oRs:SetFilter('datano = 555')
In this situation, load all table to client.
To change condition, oRs:SetFilter('datano=666') again.

or

with sql statement.
Code: Select all  Expand view
oRs:=oCn:RowSet('select * from bigdata where datano = ?', {555})
In this situation, load just my desired part of table to client.
To change condition, oRs:ReQuery({666})

My goal is change condition just two times. Which one is suitable for me. Which one is faster?

Thanks.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: filter or where statement in SQL

Postby nageswaragunupudi » Wed May 06, 2020 2:43 pm

Both work.
Let us now see the pros and cons of the two approaches.

1st method:

- Reads the entire table in the beginning itself. If it is a big table and we do not need all the rows lot of time, server and network resources are wasted
- Once read, we can change filters any number of times and there is no strain on server or network resources.

2nd method.
- Only required records are retrieved from the server.
- But each time we change the filter/where condition, we need to retrieve the new data again. Everytime this places strain on server and network resources.

So, depending on the size of the table and how large part of the table we will be needing we need to choose one of these methods.
It is a case to case decision.
Normally it is a good idea to reduce strain on server and network resources.

For example:
Sorting at the client is better than sorting on the server.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: filter or where statement in SQL

Postby Horizon » Wed May 06, 2020 5:15 pm

Hi Mr. Rao,

Code: Select all  Expand view
oRs := oCn:RowSet( "select * from `customer` where `state` = ? and 'age' between ? and ?", { cState, nMinAge, nMaxAge } )

There is a data "Source" in FWMARIAROWSET. We can see sql statement like "select * from `customer` where `state` = ? and 'age' between ? and ?"

Is there any data to see current Query variables? (not names) like {"NY",51,60}

Edit : Is there any method to inspect FWMARIAROWSET as an object with xbrowser?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: filter or where statement in SQL

Postby nageswaragunupudi » Wed May 06, 2020 5:48 pm

Yes
Code: Select all  Expand view

oRs:aParams  // undocumented.
 


We request not to use any undocumented data and rely on it in your application program. We suggest you store the current values of these parameters in your application program and also do not change oRs:aParams yourself.

These classes are complex and there are many methods and data for internal use. We need to keep them for ourselves to retain enough flexibility for future developments.

We, therefore, request you to use only the datas/methods documented in WiKi and subsequent WhatsNew.Txt.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: filter or where statement in SQL

Postby Horizon » Wed May 06, 2020 6:14 pm

nageswaragunupudi wrote:Yes
Code: Select all  Expand view

oRs:aParams  // undocumented.
 


We request not to use any undocumented data and rely on it in your application program. We suggest you store the current values of these parameters in your application program and also do not change oRs:aParams yourself.

These classes are complex and there are many methods and data for internal use. We need to keep them for ourselves to retain enough flexibility for future developments.

We, therefore, request you to use only the datas/methods documented in WiKi and subsequent WhatsNew.Txt.


Thank you Mr. Rao.

I want to ask something if it is possible.

We have a oRs object.

We create oBrw xbrowse using as a datasource oRs.

Is oRs and oBrw:oDbf objects are same object? or when you create xbrowse clone oRs to oDbf?

After creating xbrowse, if I change to Query of oRs, will oBrw:oDbf change?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: filter or where statement in SQL

Postby Horizon » Wed May 06, 2020 7:45 pm

Hi,

I think oBrw:oDbf is clone and another object.

Another question. When I set to new params with ReQuery(), browse design is gone. Which methods should run after requery?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: filter or where statement in SQL

Postby nageswaragunupudi » Thu May 07, 2020 2:35 am

oBrw:oDbf is the same as (Rowset object). It is not a clone.
When building xbrowse, oBrw:oDbf is set to oRs by using
Code: Select all  Expand view

oBrw:oDbf := oRs
 


After oRs:Requery( aNewParams ), present records are replaced by new records, but fields and columns are not changed. Therefore no changes in the browse are required. But you need to reposition the browse to the top.

Browse design is not gone.

Code: Select all  Expand view

oRs:Requery( aNewParams )
oBrw:GoTop()
oBrw:Refresh()
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 84 guests

cron