My guess is that JasperReports doesn’t see the temp table because it uses another db connection in the connection pool.
You could wrap your code up in a database transaction, this would force Servoy to use (for your session only) only 1 connection in the connection pool.
Do be aware that this connection can’t be used by other clients as long as you have this database connection open so you might want to make your connection pool a bit larger.
Yes, when it uses another connection then the one you created the temp table in then Servoy doesn’t see the temptable.
Temp tables are bound to a database connection (i.e. a session).
Using a database transaction forces Servoy to use the same connection.
The reason that the foundset fsTmp is null is that Servoy does not look for new tables every time databaseManager.getFoundset() is called.
Only at startup the list of tables is scanned.
There is an exception when the table name starts with ‘TEMP_’.
In that case Servoy will check if there is a new table with that name.
If you don’t need the foundset and you just want to pass the table to jasper reports, you can create an sql-based report where the table name is a parameter and have the table name in a parameter of the report.
The Servoy way of doing this (Servoy 6) is using databasemanager.creatDatasourceByQuery(yourSQL). It creates an in-memory table in a in-memory database on de application server. You can base a foundset on that datasource.
There is an exception when the table name starts with ‘TEMP_’.
In that case Servoy will check if there is a new table with that name.
Regards,
I have added some documentation on this in the raw sql plugin sample code:
// Note that when this function is used to create a new table in the database, this table will only be seen by
// the Servoy Application Server when the table name starts with 'temp_', otherwise a server restart is needed.