SELECT Year( date ) AS "YEAR"
FROM "transaction"
;
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/h2-database/1040186991.2923444.1708129516544%40mail.yahoo.com.
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?
Quoting transaction didn't have any effect.
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));
}