Page 1 of 1

SQL Query Search

Posted: Tue Nov 21, 2023 5:47 pm
by jtaljaard
Hi

Just wondering if someone could assist with a large database sql search that either takes incredibly long or gives an error:
Capture.PNG
Capture.PNG (19.92 KiB) Viewed 46703 times
How would one make the search faster? Here is my code so far:


Evtroutine Handling(#btnSearch.Click #edtSearch.Enter)
Clr_List Named(#lvSearch)
Execute Subroutine(#LoadTable)
Endroutine

Subroutine Name(#LoadTable)
#STD_COUNT := 1
Define Field(#wx_code) Reffld(#MPKODE)
#wx_code := 140
Check_For In_File(CDXSEN) With_Key(#wx_code)
If Cond(#IO$STS = "EQ")
Select Fields(*ALL) From_File(CDXSEN) Where(#CXBSKE.Contains( #edtSearch.Value.UpperCase )) With_Key(#wx_code)
#STD_COUNT += 1
Add_Entry To_List(#lvSearch)
Leave If(#STD_COUNT = 10)
Endselect
Else
Use Builtin(MESSAGE_BOX_ADD) With_Args('No item was found with that description.')
Use Builtin(MESSAGE_BOX_Show)
Endif
Endroutine

Re: SQL Query Search

Posted: Tue Nov 21, 2023 9:51 pm
by René Houba
Hi Jared,

This error is related to the CONNECT_FILE parameter 'Selection Limit':
CONNECT_FILE.PNG
CONNECT_FILE.PNG (24.07 KiB) Viewed 46696 times
Do you have a CONNECT_FILE builtin in your program?

If not, how do you execute your VL application?
Is this the VLF? Then you should change the 'Selection Limit' in the VLF server definition:
VLF SERVER DEFINITION.PNG
VLF SERVER DEFINITION.PNG (32.84 KiB) Viewed 46696 times

Kind regards,
René

Re: SQL Query Search

Posted: Tue Nov 21, 2023 11:59 pm
by jtaljaard
Thanks Rene

I dont suppose there is a TOP or LIMIT parameter I can use to stop the SQL query once it reaches like 20 records that match the criteria?

Re: SQL Query Search

Posted: Wed Nov 22, 2023 1:29 am
by René Houba
Hi Jared,

Correct !

Re: SQL Query Search

Posted: Thu Nov 30, 2023 10:55 am
by caseywhite
Jared. I am assuming this is VLF Windows since there is a CONNECT_FILE. In a use case like this you should consider calling a server function using the CALL_SERVER_FUNCTION BIF. Pass in the parms you need and execute that query on the server directly. This will likely be way faster because you will avoid each record being pulled down to the client to be compared.