using ALIAS function in a select

20 views
Skip to first unread message

Fawzib Rojas

unread,
Oct 29, 2019, 3:12:04 PM10/29/19
to H2 Database
I have a function datelist(startDate,endDate) returning a ResultSet that containes 2 columns firstDay,lastDay.

select * from datelist('2019-01-01','2019-03-01') as cal

This works well, returning

firstDay      lastDay
----------    ----------
2019-01-01    2019-01-31
2019-02-01    2019-02-28
2019-03-01    2019-03-31


The problem comes if I want to use any of the fields for example:

select cal.firstDay from from datelist('2019-01-01','2019-03-01') as cal

It fails saying cal.firstDate does not exists. Is there a way to use alias on functions returning resultsets, or is this a bug?




Evgenij Ryazanov

unread,
Oct 29, 2019, 9:20:11 PM10/29/19
to H2 Database
Hello.

Please, take a look on the documentation of identifiers:

You need to use "firstDay" and "lastDay" with double quotes instead, because "firstDay" and firstDay = "FIRSTDAY" are different identifiers.
Reply all
Reply to author
Forward
0 new messages