简体   繁体   中英

retrieve top 100 and then search in all records

I have window -with dw object- when i open this window i retrieve all records in the datawindow ( dw_1.retrieve() )

When user wants to search for a specific record i put criteria he enters in valid expression ( ls_filter )

then

dw_1.setfilter(ls_filter)
dw_1.filter()

My app works fine when server is on local network.

Now it is required to put server on the net(cloud) so in open event i can not retrieve all rows as it take about five minutes to retrieve all rows(very very long period).

So in sql synatx of dw_1 I added top 100 (after select) that make dw to retrieve only last 100 rows

My question is: if user want to search for specific record, is this mean i must retrieve all rows to search and thus take long time again to load all rows ?

Is this right? Or is there another solution? How?

Don't use filters. Instead you need to add retrieval argument in sql query using where clause. Now whenever you need to search the particular record, just use

Add retrieval argument from menu design -> retrieval arguments

Lets say you added retrieval argument filter varchar (100)

Your query should be :

Select top 100 * from tablename where (:filter is null and 1=1)

Or

(columnxyz like :filter)

On open() of window pass null string while retrieving.

String is_filter;  // instance variable
Setnull(is_filter);
Dw_1.retrieve (is_filter)

On retrieving filtered content only :

is_filter=sle_control.text;
Dw_1.retrieve (is_filter)

You can also visit this blog :

http://bishtpowerbuilder.blogspot.in/2016/10/4-datawindows-strength-of-powerbuilder_25.html?m=1

The correct thing is to apply a where in the dw and not use the filter. Less records less time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM