M.App Enterprise Discussions

Discuss topics with other M.App Enterprise Product pioneers and experts to get the most out of it.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Regular Contributor
Posts: 272
Registered: ‎03-10-2016
Accepted Solution

MAE Desktop: Use Alias "AS" for SQL queries

Hi there,

 

I am trying to use aliases for the column names of my query results in desktop application.

 

Therefore I want to use "AS" in my SQL statement but the results are not renamend.

 

For example when I use the follwing query:

 

SELECT id, gemeinde AS Gemeinde, strassenname AS Strasse, hausnr AS Hausnummer
FROM
alkis_gebaeude

the result is still

 

gemeinde / strassenname / hausnr

 

I think the desktop client does not support this.

Hint: The query itself works fine and delivers the results, also in studio I get a "valid query" when I check the statement.

 

Can anyone confirm this?

Is it a bug?

 

Thanks 

Stefan

GAUSS Ingenieurtechnik GmbH | Germany
Technical Evangelist
Posts: 1,144
Registered: ‎09-11-2015

Re: MAE Desktop: Use Alias "AS" for SQL queries

Hi Stefan,

 

That is strange, it works fine for me, except the action button which has wrong caption (there's bug filled for that):

 

My query

SELECT ID1, ZONE, EVT_DATE AS Date, REPORT_URL as "{ACTION.browse(urlTemplate)}" 
FROM Crime WHERE ID1 = {ENTITY.ID1} 

Results:

image-2019-08-07-15-52-58-318.png

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Regular Contributor
Posts: 272
Registered: ‎03-10-2016

Re: MAE Desktop: Use Alias "AS" for SQL queries

Hi Jan,

 

thank you for your reply.

 

Here is the whole SQL I am using (with input):

 

SELECT id, gemeinde AS Gemeinde, strassenname AS Strasse, hausnr AS HausNr, nutzung AS Nutzung, klasse AS Klasse, qualitaet_herkunft AS Qualität, o_name AS Name
FROM
alkis_gebaeude WHERE LOWER(strassenname) LIKE LOWER({ENTITY.%strassenname%}) AND hausnr LIKE {ENTITY.%hausnr%}
ORDER BY gebkennzeichen ASC

and my result attached.

 

I am using the latest version of MAE: 16.5.959.3

 

Can you please test what's happening if you use a placeholder?

GAUSS Ingenieurtechnik GmbH | Germany
Regular Contributor
Posts: 272
Registered: ‎03-10-2016

Re: MAE Desktop: Use Alias "AS" for SQL queries

Note: I am using postgres!

GAUSS Ingenieurtechnik GmbH | Germany
Technical Evangelist
Posts: 1,144
Registered: ‎09-11-2015

Re: MAE Desktop: Use Alias "AS" for SQL queries

I used MSSQL in the test. I will check with PostgreSQL...

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Technical Evangelist
Posts: 1,144
Registered: ‎09-11-2015

Re: MAE Desktop: Use Alias "AS" for SQL queries

I think I got it, please use double-quoted names when naming columns in PostgreSQL. Otherwise, the engine will automatically lower-case the column names. Example:

 

SELECT row_id, objektart as "Objekt Art", oid as "Object ID" FROM mytable;

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Regular Contributor
Posts: 272
Registered: ‎03-10-2016

Re: MAE Desktop: Use Alias "AS" for SQL queries

Hi Jan,

 

thank you for your answer! It's the solution - works fine now!

 

Regards

Stefan

GAUSS Ingenieurtechnik GmbH | Germany