databaseManager.getSQL() question

I created a foundset with this query:

var vSQL =
'SELECT distinct (orgcp.orgcp_id)  
FROM orgcp
 INNER JOIN contact contact1 ON  orgcp.contact_id  = contact1.contact_id
 INNER JOIN contact_item contact_item1 ON  orgcp.orgcp_id = contact_item1.orgcp_id WHERE  contact1.gender = 1 AND contact_item1.phone IS NOT NULL 
AND orgcp.owner_id = 1
ORDER BY orgcp.orgcp_id'

After loading the records (which works fine with controller.loadRecords(vSQL)), I want to retrieve the SQL again from the foundset by:

var vNewSQL = databaseManager.getSQL(foundset)

vNewSQL returns this -strange- query:

select orgcp_id from orgcp inner join #TEMP_8146842016 TEMP814684201665844 on orgcp_id=TEMP814684201665844.orgcp_id_8146842018 order by organisation_name asc

Is this a Servoy issue or is there a way to retrieve the correct query?

Version 3.5.2_04-build 515
Java version 1.6.0_02-b06 (Windows XP)
Sybase 10

Hi Karel,

Servoy 3.5 may use temporary tables to sort data if you sort by a related field, which may explain that strange query.

I’m also relying on databaseManager.getSQL(foundset) to give me the last query - and I’m wondering if this will work properly…