Searching a by SolutionModel created DataSource

Questions, tips and tricks and techniques for scripting in Servoy

Searching a by SolutionModel created DataSource

Postby ROCLASI » Fri May 29, 2009 1:57 pm

I have a dynamically created form that uses a datasource provided by a dataset. So the form is not directly linked to a server and/or table.
When I try to search in this form using custom code and the correct SQL then get an error that it can't find the table.
Code: Select all
Error loading primary key data, org.apache.commons.dbcp.DbcpException: java.sql.SQLException:
  Table not found in statement [select "_sv_rowid" from "TEMP_7_ad574a26-df61-44c7-ac0b-cc644492516b"  where "_sv_rowid" in (SELECT pk_id,unique_name FROM individuals WHERE upper(unique_name) LIKE upper(%?%)) order by "_sv_rowid" asc]

java.sql.SQLException:
  Table not found in statement [select "_sv_rowid" from "TEMP_7_ad574a26-df61-44c7-ac0b-cc644492516b"  where "_sv_rowid" in (SELECT pk_id,unique_name FROM individuals WHERE upper(unique_name) LIKE upper(%?%)) order by "_sv_rowid" asc]
(error formatted for better readability)

Is this a limitation of working with custom datasources ?


Servoy 4.1.2 and 4.1.3
SQL Server 2005 (jtds)
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Searching a by SolutionModel created DataSource

Postby ptalbot » Mon Jun 01, 2009 1:22 am

Hi Robert,

I have had the same kind of trouble some time ago, when using a memory DataSource, Servoy insisted to generate SQL to update my record.

I haven't found a workaround, I thought it was me so I just forgot about it and made things completely differently.
I am glad to know that I am not alone, but not glad to know that this problem is real when using memory DataSource on a form.

It looks like a bug to me.
You should submit a case to the support system.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Searching a by SolutionModel created DataSource

Postby rgansevles » Wed Jun 03, 2009 11:50 pm

Robert,

Can you show a snippet of the code?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Searching a by SolutionModel created DataSource

Postby ROCLASI » Tue Jun 09, 2009 2:07 pm

Hi Rob,

Here is some simplified code that reproduces the problem.

Code: Select all
function CustomDatasourceQuery()
{
   var sForm    = "myTestForm",
      sServer   = "ihe"
      sQuery    = "SELECT pk_id,unique_name FROM individuals",
      nWidth    = 600,
      nHeight   = 500;

   ds = databaseManager.getDataSetByQuery(sServer,sQuery,null,-1);
   oForm = solutionModel.newForm(sForm ,ds.createDataSource("myData",[DM_COLUMNTYPE.INTEGER,DM_COLUMNTYPE.TEXT]),null,false,nHeight,nWidth);

   application.showFormInDialog(forms[sForm],-1, -1, nWidth, nHeight, "Test Form", false, false, sForm, false);

   // lets load it again. ==> ERROR
   forms[sForm].controller.loadRecords(sQuery);

}
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Searching a by SolutionModel created DataSource

Postby rgansevles » Tue Jun 09, 2009 8:30 pm

Robert,

When you create a form on a data set, the form works with this data and is not based on a database table, regardless where the data came from (a query, a file, etc).
Therefore you cannot use loadRecords(sql) on it since it has no link to the database anymore.

If you want to reload you will have to create a new data set, create a new data source from it and assign it to the forms dataSource property (or create a new form).
Note that the runtime form has to be recreated for it, because you are changing the form design.

A ds.removeRow(-1) will delete all data of the old data set, you may need that to prevent a memory leak.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL


Return to Methods

Who is online

Users browsing this forum: Bing [Bot] and 40 guests

cron