Thanks for checking Evgenij. I was mistaken - adding "YEAR" to the 
"NON_KEYWORDS" does indeed work. There was a different issue on my end that was 
throwing things off. Appreciate everyone's help.
Best,Peter

    On Saturday, February 17, 2024 at 02:19:07 AM EST, Evgenij Ryazanov 
<kat...@gmail.com> wrote:  
 
 Hello!

YEAR is a reserved word even in archaic SQL-92, so it was a bad idea to use it 
as unquoted identifier. BTW, DATE and TRANSACTION are reserved words too, but 
H2 allows their usage as identifiers. Also there is no YEAR function in the 
Standard, correct syntax is EXTRACT(YEAR FROM someValue).

Newer versions of H2 may have more keywords than old versions and reserved 
words from the latest version of the SQL Standard (from SQL:2023 for now) are 
potential candidates.
 
Anyway, the following test case prints 2024 as expected, so NON_KEYWORDS 
settings works well and you have some other problem in your application, most 
likely your query is executed from a connection with different settings.


Properties p = new Properties();

p.put("MODE", "PostgreSQL");

p.put("DATABASE_TO_LOWER", "TRUE");

p.put("DEFAULT_NULL_ORDERING", "HIGH");

p.put("NON_KEYWORDS", "YEAR");

try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:", p)) {

 Statement s = connection.createStatement();

 s.execute("CREATE TABLE transaction(date DATE) AS VALUES CURRENT_DATE");

 ResultSet rs = s.executeQuery("SELECT year(date) AS year FROM transaction");

 rs.next();

 System.out.println(rs.getInt(1));

}


-- 
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/fc4ea7a4-c9f8-47a1-89be-191e9d807f15n%40googlegroups.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/797384501.3014179.1708171658213%40mail.yahoo.com.

Reply via email to