<-- Back

Using SELECT * in OQL queries causes error "All columns of the first select query must have a correct name"

Issue

When using SELECT * FROM Main.TestEntity in an OQL query, this triggers the following error:

 All columns of the first select query must have a correct name: An attribute must have a simple name or an alias. 

This happens when trying to select all attributes of an entity dynamically using the asterisk wildcard character.

Environment

Studio Pro (all versions)

Cause

Using SELECT * is intentionally not supported in the topmost SELECT statement of OQL queries. The reason is that the topmost SELECT determines which attributes the entity should have in the domain model. If * were allowed, the entity's attributes would be determined by other entities, meaning that adding a column to those entities or to an inner SELECT would automatically change the attributes in the domain model. This would create unpredictable behavior and potential issues with domain model integrity.

Solution/Workaround

To resolve this issue, explicitly list all attributes in the SELECT statement instead of using the asterisk wildcard. For example:

  • Incorrect: SELECT * FROM Main.TestEntity
  • Correct: SELECT Attribute1, Attribute2, Attribute3 FROM Main.TestEntity

Note that while SELECT * cannot be used in the topmost SELECT that defines entity attributes, it may be used in inner SELECT statements within the query.

Internal information related

  • 264509
  • C06635P1EKA/p1762784704468139

Additional information

Mendix documentation: OQL

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.