Good Morning.

`YEAR` is a SQL:2016 reserved
keyword: 
http://www.h2database.com/html/advanced.html?highlight=keyword&search=keyword#keywords
You will need to quote your alias:

SELECT Year( date ) AS "YEAR"
FROM "transaction"
;

Similar thing for `TRANSACTION`.
It is always advisable to avoid such keywords are object identifiers.

Cheers
Andreas


On Sat, 2024-02-17 at 00:25 +0000, 'Peter Borissow' via H2 Database
wrote:
> Dear H2 Community,
>     I ran into an unexpected error today migrating from 1.x to 2.x.
> I'm using H2 2.2.224 in PostgreSQL mode using the following
> parameters
>
> properties.setProperty("MODE", "PostgreSQL");
> properties.setProperty("DATABASE_TO_LOWER", "TRUE");
> properties.setProperty("DEFAULT_NULL_ORDERING", "HIGH");
>
> The following query is failing:
>
> select year(date) as year from transaction
>
> Error:
>
> SELECT year(date) AS [*]year FROM transaction"; expected "identifier"
>
> Looks like it doesn't like the year alias in the select statement.
> The following query works:
>
> select year(date) as y from transaction
>
> I tried the following but it didn't seem to help:
>
> properties.setProperty("NON_KEYWORDS", "YEAR");
>
> Any suggestions?
>
> Thanks,
> Peter
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to h2-database+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/h2-database/1040186991.2923444.1708129516544%40mail.yahoo.com
> .

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/83c98a852da9a0ef3683051984c612304744c66c.camel%40manticore-projects.com.

Reply via email to