How to query a View with SQLRunner

Trying to query a viewentity with SQLRunner, however, I’m getting that the table doesn’t exist. Is it possible to select rows from this view, if so, how?

ERROR:
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table “MY_VIEW_TABLE” not found; SQL statement:

1 Like

moqui itself has ability to show all view entities on the entity view screen. You either query with wrong statement or the view construction is not correct.

Post definition and query statement, someone with experience can understand what you did.

1 Like

A view entity in moqui is not a database view, it is a query that is constructed on the spot when you execute an entity find. Therefore you cannot use SQL on view entities.

Now with that being said, a view entity can be sophisticated in its design using conditions and other constructs.

For more dynamic behavior in making your view moqui offers the EntityDynamicView which can help construct throw away view entities that can be constructed at runtime.

2 Likes