multiple addTableFilterParam

Questions, tips and tricks and techniques for scripting in Servoy

Re: multiple addTableFilterParam

Postby david » Fri Nov 07, 2008 6:41 pm

Sorry to mislead you, my code has an error in it. I wrote it by hand and had SQL query format in my head.

The upshot is that the value parameter of the addTableFilterParam either needs to be one value (string or number) or an array if passing multiple values. So my code above corrected:

Code: Select all
var NestedIN = "SELECT jobcode FROM core_rso_emp WHERE jobcode IN('3440','4958','3465','4959','0000')"
var values = databaseManager.getDataSetByQuery(controller.getServerName(), NestedIN, null, 10000000)
valuesArray = values.getColumnAsArray(1)
databaseManager.addTableFilterParam('rcs_billing_sharedcore', 'core_rso_emp', 'jobcode', 'IN', valuesArray)
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1724
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: multiple addTableFilterParam

Postby ngervasi » Fri Nov 07, 2008 9:35 pm

Hey David, maybe you were typing in a hurry but beware of this:

Code: Select all
var values = databaseManager.getDataSetByQuery(controller.getServerName(), NestedIN, null, 10000000)


Always use -1 unless you are 100% sure that the query will give you a predefined amount of records back, I know it looks stupid but if in the future your query will return more than 10000000 records you'll be in deep trouble and debugging things like this can be a real nightmare.
So this is the correct code:

Code: Select all
var values = databaseManager.getDataSetByQuery(controller.getServerName(), NestedIN, null, -1)


Sorry to be so picky but it happened to a colleague of mine and we had our share of pain and lost one day to figure out what was wrong.
ngervasi
 
Posts: 1475
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: multiple addTableFilterParam

Postby david » Fri Nov 07, 2008 10:12 pm

I guess that would make for a tough debugging job :) Great reminder.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1724
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: multiple addTableFilterParam

Postby achiary » Mon Nov 10, 2008 5:27 pm

Thanks David, for clarifying the format of 'value' as an array when the operator is 'IN', it is not in the manuals.

So I could make it work also in the following way :

Code: Select all
var arrayprov = new Array(1,6,15);
   application.output(arrayprov  )
   databaseManager.addTableFilterParam( 'cotizaciones',  'clientes',  'provincia',  'IN',  arrayprov)


So, when the IN values are already known (in my case provincias 1,6 and 15) I can fill an array and I do not need to perform a query.
I guess the query must be used when the result is unknown and depends on a certain condition.
achiary
 
Posts: 81
Joined: Wed Nov 14, 2007 3:29 pm
Location: Argentina

addTableFilterParam related data

Postby lwjwillemsen » Wed Sep 17, 2014 7:49 am

Hi,

Any news on using relations in the addFilterParam() ?
Using pk_field in (select ...) performs (still) bad (no 200 records limit in subquery).

Or any other solution ?

Regards,
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 569
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands

Re: multiple addTableFilterParam

Postby steve1376656734 » Sun Sep 21, 2014 10:06 am

Hi,

I have logged a feature request for this as SVY-7063. Please vote for it :D

Thanks
Steve
Steve
SAN Developer
steve1376656734
 
Posts: 180
Joined: Fri Aug 16, 2013 2:38 pm
Location: Lanzarote

Previous

Return to Methods

Who is online

Users browsing this forum: No registered users and 4 guests

cron