Hi Andreas,   Thanks for the quick reply! As you suggest, quoting "year" as 
the alias works. Quoting transaction didn't have any effect. Several questions:
(1) What doesn't this work?
properties.setProperty("NON_KEYWORDS", "YEAR");
(2) I am in PostgreSQL mode. On a PostgreSQL server, I don't have to quote year 
as an alias in PostgreSQL in a statement like this:select date as year from 
transaction
Why do I have to quote year? Why has the behavior changed from 1.x to 2.x?

Thanks in advance!Peter


    On Friday, February 16, 2024 at 07:31:03 PM EST, Andreas Reichel 
<andr...@manticore-projects.com> wrote:  
 
 Good Morning.
`YEAR` is a SQL:2016 reserved keyword: 
http://www.h2database.com/html/advanced.html?highlight=keyword&search=keyword#keywordsYou
 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.
CheersAndreas

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.
  

-- 
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/1548447917.2938581.1708130867832%40mail.yahoo.com.

Reply via email to