Using database view as datasource forform -> PK ERROR

Questions and answers for designing and implementing forms in Servoy

Using database view as datasource forform -> PK ERROR

Postby v.weimer » Fri Aug 23, 2019 8:52 am

Hi,

scenario:
- create a view in a database (maxdb)
- bind this view to a form to show data as datasource (filter the view before displayed with find-search)
-> in developer everything is fine, but after deploy I get always a PK error for the view in servoy admin page and a crash on the page - no data is shown.

deploy server is a Tomcat on suse linux SLED 15.1 java 9.

Could anyone suggest a solution and/or explain why.

Thanks in advanced.
v.weimer
 
Posts: 14
Joined: Mon Sep 05, 2016 8:04 am

Re: Using database view as datasource forform -> PK ERROR

Postby v.weimer » Thu Sep 05, 2019 2:48 pm

Hi together,

I investigated a bit more time and could now give a better summary of what happens.

The form uses a FoundSets of "table A" and I do have 3 Table WebComponetns on that form. Those WebComponetns do use database views (not related to "Table A") as separate FoundSets.
Now I do a find/search on one of the FoundSets based on a database view and used by the Table WebComponetns.
This produces the exception. No pk ...

As long as I use for the Table WebComponetns the FoundSet of the underlying form I can perform a find/search without any error. I guess a real Table would course no issues, too.

Bug or intended?

Workaround is currently to separate the Table WebComponetns in forms and use a tabless panel to show the form/data. The form and Table WebComponetns do have the same datasource (database view) and everything is fine with find/search.
v.weimer
 
Posts: 14
Joined: Mon Sep 05, 2016 8:04 am

Re: Using database view as datasource forform -> PK ERROR

Postby mboegem » Thu Sep 05, 2019 6:45 pm

Hi v.weimer,

Most likely your view doesn't have a pk, or at least that is not known as pk (or dbident) to Servoy.
That's what causing the error.

Please be aware: since views are updated on database level, Servoy is not aware of any changes in the data and therefor won't update your formdata using dataBroadcasting.

I don't know why you are using views, but there are a few 'Servoy way' options to get your data from the database into Servoy without retrieving all columns of a table (what Servoy will do by default).
1) use datasets and Servoy's power-grid
2) use datasets, turn them into in-memory datasources and use Servoy's ng-grid
3) use the recently introduced view-foundset and again use Servoy's ng-grid

The latter uses the built-in Querybuilder object and you will be able to set whether you expect any updates from databroadcast.
The first 2 options will not support any updates through databroadcasting.

Hope this helps.
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Forms

Who is online

Users browsing this forum: No registered users and 5 guests