Hi all: I am still fairly new to Servoy and running into as yet unexplored territory. Servoy Talk generally gives me an answer: congrats to all who contribute. But this one has me really stumped.
I have the following line in a method:
var vDataset = databaseManager.getDataSetByQuery(controller.getServerName(), sqlstring, arguments, 9999)
Notice that I have two variables: ‘sqlstring’ and ‘arguments’.
The variable sqlstring in a test example is:
select id_person from people where present_location_country like ? or surname like ? or first_name like ? order by surname asc, first_name asc
I have a problem with setting the variable ‘arguments’ correctly. Reading Servoy Talk and the Servoy Reference Guide I can see there are issues over arrays and objects.
My example has arguments in an array of 3 elements: [‘%Marten%’,‘%Marten%’,‘%Marten%’]. In essence, I am looking for records containing the string ‘Marten’ in one of a number of fields.
CASE 1: Forget about setting arguments and specify the array directly:
var vDataset = databaseManager.getDataSetByQuery(controller.getServerName(), sqlstring, [‘%Marten%’,‘%Marten%’,‘%Marten%’], 9999)
Result: OK – a correct foundset of 9 records in my sample database of 45,000 records.
CASE 2: Set var arguments = [‘%Marten%’,‘%Marten%’,‘%Marten%’] before executing the original vDataset declaration.
Result: OK – same foundset.
CASE 3: Declare arguments = new Array. Set argument[0] = ‘%Marten%’ and so on for [1] and [2].
Result: A foundset of 0 records.
In my scenario I need to set the arguments programmatically (as in case 3). Fixed arguments as it cases 1 and 2 will not do. However, I have yet to come up with a way of doing this that works.
Does anyone have any thoughts on how this might be done?
Richard Hinder
London
Development environment:
Servoy Developer
Version 3.5.5-build 518
Java version 10.0-b19 (Windows XP)
Sybase for repository
PostgreSQL 8.3 for sample data