Re: [h2] insert with on conflict do nothing not working

2022-04-05 Thread Andreas Reichel
Tom,

from the docs:

PostgreSQL Compatibility ModeTo use the PostgreSQL mode, use the database
URLjdbc:h2:~/test;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;DEFAULT_NULL_O
RDERING=HIGH. Do not change value of DATABASE_TO_LOWER after creation
of database.
 * For aliased columns, ResultSetMetaData.getColumnName()
   returns the alias name and getTableName() returns
   null.
 * When converting a floating point number to an integer, the
   fractional
   digits are not be truncated, but the value is rounded.
 * The system columns ctid and
   oid are supported.
 * LOG(x) is base 10 in this mode.
 * REGEXP_REPLACE():
   uses \ for back-references;does not throw an exception when the
   flagsString parameter contains a 'g';replaces only the first matched
   substring in the absence of the 'g' flag in the flagsString
   parameter.
 * LIMIT / OFFSET clauses are supported.
 * Legacy SERIAL and BIGSERIAL data types are supported.
 * ON CONFLICT DO NOTHING is supported in INSERT statements.
 * Spaces are trimmed from the right side of CHAR values, but CHAR
   values in result sets are right-padded with
   spaces to the declared length.
 * MONEY data type is treated like NUMERIC(19, 2) data type.
 * Datetime value functions return the same value within a transaction.
 * ARRAY_SLICE() out of bounds parameters are silently corrected.
 * EXTRACT function with DOW field returns (0-6), Sunday is 0.
 * UPDATE with FROM is supported.
 * GROUP BY clause can contain 1-based positions of expressions from
   the SELECT list.

It should work. What is your connection setting please?
Best regards
Andreas

On Tue, 2022-04-05 at 16:28 -0700, Tom wrote:
> hi All,
> 
> Is there anything special that I need to do to get ON CONFLICT DO
> NOTHING working with Postgresql? I'm using H2 2.1.210  (and I know it
> has been added since H2 1.4.200 in 2019) with PostgreSQL10Dialect
> (H2Dialect doesn't work either) but what I get is 
> 
> on statement:
> 
> insert into transaction_type (transaction_type, description) values
> ('sometx', 'xx') ON CONFLICT DO NOTHING;
> 
> I get: 
> 
> org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL
> statement "insert into transaction_type (transaction_type,
> description) values ('sometx', 'xx') [*]ON CONFLICT DO NOTHING";
> SQL statement:
> insert into transaction_type (transaction_type, description) values
> ('sometx', 'xx') ON CONFLICT DO NOTHING [42000-210]
> 
> help?
> 
> Tom
> -- 
> 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/03b164cf-e394-4109-9bf5-ebb7d7dcb6edn%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/dbb2bdf904e60e57bd2330d957b6ee29feb955fe.camel%40manticore-projects.com.


[h2] insert with on conflict do nothing not working

2022-04-05 Thread Tom
hi All,

Is there anything special that I need to do to get ON CONFLICT DO NOTHING 
working with Postgresql? I'm using H2 2.1.210  (and I know it has been 
added since H2 1.4.200 in 2019) with PostgreSQL10Dialect (H2Dialect doesn't 
work either) but what I get is 

on statement:

insert into transaction_type (transaction_type, description) values 
('sometx', 'xx') ON CONFLICT DO NOTHING;

I get: 

org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement 
"insert into transaction_type (transaction_type, description) values 
('sometx', 'xx') [*]ON CONFLICT DO NOTHING"; SQL statement:
insert into transaction_type (transaction_type, description) values 
('sometx', 'xx') ON CONFLICT DO NOTHING [42000-210]

help?

Tom

-- 
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/03b164cf-e394-4109-9bf5-ebb7d7dcb6edn%40googlegroups.com.