[h2] array_agg() with order by not working correctly

2018-05-16 Thread Thomas Kellerer
Consider the following setup: create table x (a int, b int); insert into x values (1,1), (1,2), (2,5), (2,6), (2,7); Now run the following query: select a, array_agg(b) from x group by a; This returns: A | ARRAY_AGG(B) - 1 | (1, 2) 2 | (5, 6, 7) Now if you add an

Re: [h2] CTE name resolution wrong (or at least non-standard)

2017-06-30 Thread Thomas Kellerer
But to be consistent you would need to throw an exception for derived tables as well, as they have the same visibility. However, the following works as expected (given the table definitions from my initial post): select * from ( select c3, c4 + 42 from b ) a; Am Freitag, 30. Juni 2017

[h2] CTE name resolution wrong (or at least non-standard)

2017-06-26 Thread Thomas Kellerer
Consider the following sample data: create table a (c1 integer, c2 integer); create table b (c3 integer, c4 integer); insert into a values (1,1), (2,2); insert into b values (3,3), (4,4); with a(col1, col3) as ( select c3, c3 + 42 from b ) select * from a; The above returns C1 | C2

[h2] Re: Anybody actively working on support for ROW_NUMBER() OVER ([PARTITION BY])?

2017-03-20 Thread Thomas Kellerer
That syntax is already supported by H2 since version 1.4.177 (see: http://www.h2database.com/html/changelog.html) However, the "fetch first" variant is apparently not yet documented. Am Sonntag, 19. März 2017 10:29:11 UTC+1 schrieb Philippe Marschall: > > Now that 12c supports row limiting >

[h2] Errors in the DBMS comparison

2016-08-30 Thread Thomas Kellerer
I think there are some errors in the DBMS comparison at: http://www.h2database.com/html/features.html#comparison Postgres has "Linked tables" through Foreign Data Wrappers: https://wiki.postgresql.org/wiki/FDW (which is available since V9.0 which that comparison is based upon) Neither

Re: Simulating Oracle || in H2

2010-12-29 Thread Thomas Kellerer
Not sure what you are asking, because the || concatenation operator works in H2 the same as in all other standard compliant databases. On Dec 29, 11:00 pm, leojhartiv leo.h...@gmail.com wrote: We're currently using H2 as our local development database, while Oracle is our production database

Re: Common table expressions

2010-08-05 Thread Thomas Kellerer
On Aug 2, 2:31 pm, Thomas Mueller thomas.tom.muel...@gmail.com wrote: You have a serious complexity problem here. No I don't ;) These are aggregating reports that do some pretty nifty aggregation calculation on a daily basis. And in order to re-use the intermediate results CTEs are very

Re: Common table expressions

2010-07-28 Thread Thomas Kellerer
On Jul 28, 8:26 pm, Thomas Mueller thomas.tom.muel...@gmail.com wrote: As far as I can tell this currently *only* works for recursive queries - at least I could not get a non-recursive CTE to work. Yes, that's possible. I only tested the recursive case. I think that's the main reason to use

Common table expressions

2010-07-26 Thread Thomas Kellerer
Hi, in the last version Experimental support for recursive queries (= common table expressions) was added, which is very cool! As far as I can tell this currently *only* works for recursive queries - at least I could not get a non-recursive CTE to work. Is it planned to extend this to a

Re: ROWNUM behavior

2010-05-15 Thread Thomas Kellerer
Thanks for the feedback. What I find confusing is, that the rownum is reset when handed from a derived table to the upper select (see my example earlier) Having the rownum assign the numbers for each partial select would be more consistent (until windowing functions with row_number() are

Re: ROWNUM behavior

2010-05-14 Thread Thomas Kellerer
On May 14, 12:22 pm, Rami Ojares rami.oja...@gmail.com wrote: 14.5.2010 13:00, Thomas Kellerer kirjoitti: On May 14, 11:40 am, Kerry Sainsburyke...@fidelma.com  wrote: Sorry -- I don't know! I don't see much value in rownum() either. I've never needed or wanted to use it for anything

Re: A bug in 1_install_service.bat?

2010-04-26 Thread Thomas Kellerer
On Apr 26, 6:43 am, Thomas Mueller thomas.tom.muel...@gmail.com wrote: Hi, What about adding this at the very beginning: cd %~dp0 Regards, Thomas I think simply using %~dp0 makes it more stable and easier to use for other scripts. If you do change the current directory that might confuse

Re: A bug in 1_install_service.bat?

2010-04-23 Thread Thomas Kellerer
On Apr 23, 7:47 pm, Thomas Mueller thomas.tom.muel...@gmail.com wrote: Hi, When executing as admin, the default directory is c:\windows\system32 Do you mean, if you double-click it?  and the script fails since it has relative paths. Would be nice to add a cd command to fix that. Could

Re: How to insert a file into a blob field from sql statement

2010-04-09 Thread Thomas Kellerer
On Apr 9, 4:30 pm, dmiche...@googlemail.com dmiche...@googlemail.com wrote: For instance, if I want to test my sql statement from the H2 GUI front- end before doing via my JDBC java code. I tried to pass the path , i.e. INSERT INTO mytable (id,name,file)

Re: How to set SysProperites.USER_HOME in Tomcat?

2010-03-22 Thread Thomas Kellerer
You have two easy options: Create a global environment variable named JAVA_OPTS and the contents -Duser.home=/path/to/your/home/dir or create a script setenv.bat (or setenv.sh) in $CATALINA_HOME/bin that contains the above environment variable. Thomas On Mar 22, 9:15 pm, Thomas Mauch

Re: Sort order not stable (1.1.118)

2010-02-10 Thread Thomas Kellerer
On Feb 10, 10:05 am, Remo remo.ma...@gmail.com wrote: @Thomas I do have an ORDER BY in my query. But due to equal values, there is not one single correct order. If the db engine uses stable sorting algorithms, the rows should be returned in the same order over multiple runs. Ah sorry,

Re: Sort order not stable (1.1.118)

2010-02-09 Thread Thomas Kellerer
The only(!) way to get a deterministic ordering from a relational database is to use ORDER BY. Just because you get a consistent ordering between two different runs (in some databases), does not mean you get it on a third run. As soon as you insert or update or even change the WHERE condition,

Cannot drop primary key

2010-02-05 Thread Thomas Kellerer
Hi, maybe I'm missing something, but the following statement ALTER TABLE my_table DROP PRIMARY KEY; fails with the error message: Index PRIMARY_KEY_14E belongs to a constraint When I run ALTER TABLE my_table ADD CONSTRAINT PK_MY_TABLE it is working. According to the SQL Grammer description

Re: Cannot drop primary key

2010-02-05 Thread Thomas Kellerer
when dropping a column that is a (single column) foreign key. It cannot be dropped unless I drop the FK constraint first :( On Feb 5, 10:31 am, Thomas Kellerer google-gro...@sql-workbench.net wrote: Hi, maybe I'm missing something, but the following statement ALTER TABLE my_table DROP PRIMARY

Re: what is the syntax for inserting records from one table into another that doesn't exist in that table

2010-02-01 Thread Thomas Kellerer
This should work INSERT INTO target_table (id, some_data) SELECT id, some_data FROM other_table o WHERE NOT EXISTS (SELECT 1 FROM target_table t1 WHERE o.id = t1.id); Assuming column ID is the primary key in both tables. On Feb 1, 10:03 pm, gabjos sikyala_raq...@bah.com wrote: I need to

Re: quotes

2010-01-19 Thread Thomas Kellerer
On Jan 19, 8:53 pm, Thomas Mueller thomas.tom.muel...@gmail.com wrote: The best of course would be to allow case sensitivity as well but I gather that that is harder to implement. There is a reason why standards exists and just because they are ignored by Microsoft or (even more so) by the

Re: Result Sets

2010-01-19 Thread Thomas Kellerer
On Jan 17, 4:50 pm, ggrothendieck ggrothendi...@gmail.com wrote: Is there documentation which tells one which SQL statements return a result set and which ones do not. You can always use the generic execute() method and then test for result sets and/or update counts:

Re: Disable Constraint

2009-12-29 Thread Thomas Kellerer
On Dec 29, 11:48 pm, Nitai @ Razuna ni...@razuna.com wrote: thus the question is it possible to disable constraint checking for the complete database or single tables? http://www.h2database.com/html/grammar.html#set_referential_integrity -- You received this message because you are subscribed

User defined functions can be created with source code in 1.2.124

2009-11-20 Thread Thomas Kellerer
Hi, I have seen the new feature to add new function directly with Java source code. Pretty cool feature. Is there a way to retrieve the Java source somehow, or is that not stored in the system tables? I checked INFORMATION_SCHEMA.FUNCTION_ALIAS but as far as I can tell, the source is not

Re: Read sequences from the metadata

2009-09-07 Thread Thomas Kellerer
           DatabaseMetaData meta = connection.getMetaData();            rs = meta.getTables(connection.getCatalog(), schemaName, null, new String[]{ SEQUENCE }); I didn't know about this, what databases support this feature? The Postgres JDBC driver does, if I remember correctly

Re: h2 as a cache for postgres

2009-08-22 Thread Thomas Kellerer
Yeah, but postgres views are not writable :( Yes, they are through the use of rules. It's a bit cumbersome especially when you need to do that for a large number of view, but it works --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Re: default escape character in like clause

2009-08-13 Thread Thomas Kellerer
On 9 Aug., 16:53, charly gartenzwer...@googlemail.com wrote: This would be a proprietary feature of H2 (and maybe other databases like the above mentioned Oracle) and is fine, if  the SQL-statements are running only on H2  i.e. need not be portable. I'm not sure what kind of escaping is

Re: default escape character in like clause

2009-08-13 Thread Thomas Kellerer
But it seems its not standard 1. that there is a default ESCAPE char active, if the keyword ESCAPE is NOT used Correct. The standard requires that no escaping takes place if ESCAPE is not specified. 2. that ESCAPE ''  i.e. with empty string (meaning no escape char active)  can be provided

Re: ROWNUM Function Behavior

2009-08-03 Thread Thomas Kellerer
On 3 Aug., 21:10, Thomas Mueller thomas.tom.muel...@gmail.com wrote: I don't think it's incorrect. It matches the documentation, and as far as I know it works like Oracle. Right, this is exactly the way Oracle's ROWNUM behaves (although in Oracle it's not a function, so ROWNUM() does not

Re: Any thoughts on making java stored procedures follow the SQLJ Part 1 standard?

2009-07-13 Thread Thomas Kellerer
On 11 Jul., 17:46, Thomas Mueller thomas.tom.muel...@gmail.com wrote: I didn't know there is a standard... Do you have a link to the standard? I think it's called: SQL/PSM (Persistent Stored Modules) and is implemented in HSQLDB 1.9 beta and (IIRC) DB2. Thomas

Regression in ResultSetMetadata.getColumnName()

2009-06-20 Thread Thomas Kellerer
Hi, with V1.0.79 the following SELECT statement would return MY_ID for ResultSetMetaData.getColumnName(1) SELECT id as my_id FROM my_table with 1.1.114 getColumnName() returns ID Is that indended? Regards Thomas --~--~-~--~~~---~--~~ You received this

Re: Java 1.5, but still support Java 1.4 using Retrotranslator, Retroweaver, or using -target jsr14:

2009-05-17 Thread Thomas Kellerer
16, 2009 at 6:44 PM, Thomas Kellerer google-gro...@sql-workbench.net wrote: I don't think support for 1.4 is important. How long is it that this has been de-supported by Sun? Even 1.5 will be de-supported by Sun end of this year (October). Just my .02€ Thomas On 16 Mai, 12:20

Re: Java 1.5, but still support Java 1.4 using Retrotranslator, Retroweaver, or using -target jsr14:

2009-05-16 Thread Thomas Kellerer
I don't think support for 1.4 is important. How long is it that this has been de-supported by Sun? Even 1.5 will be de-supported by Sun end of this year (October). Just my .02€ Thomas On 16 Mai, 12:20, Thomas Mueller thomas.tom.muel...@gmail.com wrote: Hi, So far the H2 source code is

Re: test database setup/flushing

2009-04-07 Thread Thomas Kellerer
My, granted very small, test suite now takes ~1.1s on postgres and ~0.6s with H2. So, almost 2x as fast. Not a big deal now, but on larger test suites, that will be nice. A bit off-topic here: For Postgres you could setup your schema in a template database. When you want to run your tests,

Re: How to fill Blob object when Blob.setBytes is not supported?

2009-03-04 Thread Thomas Kellerer
Methods setBytes and setBinaryStream are not supported (H2 throws Unsupported Exception). How can I use Blob? Is it even possible? This works for me: PreparedStatement stmt = connection.prepareStatement(INSERT INTO blob_table (blob_column) VALUES (?); InputStream blobData = new

Re: Sum of zero rows

2009-02-03 Thread Thomas Kellerer
On 2 Feb., 19:36, Mike Goodwin mkpgood...@gmail.com wrote: It surprised me that the sum over 0 rows comes to null and not zero. So what is the sum of nothing? DROP TABLE IF EXISTS x; CREATE TABLE x (val INTEGER); INSERT INTO x values (null); SELECT sum(val) FROM x; also returns null.

Re: Getting the last few recent records

2009-01-24 Thread Thomas Kellerer
If you have a column that contains the creation timestamp in your table then you can use the following: select * from my_table where datediff('MINUTE', created_at, current_timestamp) = 2; will return all records that were created in the last two minutes. On 24 Jan., 10:42, Thotheolh

Re: Case-sensitive table names without quotes?

2009-01-23 Thread Thomas Kellerer
Hi, MySQL and MS SQL Server compatibility: support case sensitive (mixed case) identifiers without quotes. Thanks! If I had the slightest hope that it would help I'd file an issue with MySQL and Microsoft to make them respect the ANSI standard a lot more :) By the way, do you have a link to

Re: Preservation of table names with both lowercase and uppercase letters

2009-01-15 Thread Thomas Kellerer
One question though: are there plans to support preservation of case in table names without in H2 in the near future? I doubt that this will be implemented (for time and other reasons as Thomas has explained to me in another posting) But: you are aware that this would make H2 non-compliant

Case-sensitive table names without quotes?

2009-01-12 Thread Thomas Kellerer
Hi, I have a rather strange question: I'm using H2 a lot to do unit testing on my application. Now SQL Server (and MySQL) can be configured to be case-sensitive for table names even without double quotes. As much as I dislike this behaviour, I need to test my application if it can cope with