sagarswathi / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Array Readability Issue #577

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please send a question to the H2 Google Group or StackOverflow first,
and only then, once you are completely sure it is an issue, submit it here.
The reason is that only very few people actively monitor the issue tracker.

Before submitting a bug, please also check the FAQ:
http://www.h2database.com/html/faq.html

What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1. using runtool, against a database, in which, there is a column which is an 
Array. Containing at least 4-6 values.
2. Now, try to perform a csvwrite against this database, and print a range of 
array values, say from array[0] to array[5].
3. It seems like it is not possible yet....as the tutorial on the website, did 
not provide much information about fetching range values.

What is the expected output? What do you see instead?
I wanted to see a csv file, which would have printed the array contents from 
position 0 to position 5 on each row.
Instead, saw an error 
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Syntax error in SQL 
statement "SELECT 
TIME,SYMBOL,CP,Array1[1,[*]2],Array2[1,2],Array3[1,2],Array4[1,2] FROM Table 
WHERE Search='XYZ' "; expected "[, ::, *, /, %, +, -, ||, ~, !~, NOT, LIKE, 
REGEXP, IS, IN, BETWEEN, AND, OR, ]"; SQL statement:

What version of the product are you using? On what operating system, file
system, and virtual machine?
H2 1.4.180

Do you know a workaround?
No

What is your use case, meaning why do you need this feature?
Inhouse tool for data analysis.

How important/urgent is the problem for you?
It is a very important issue, but not that urgent. But a quick solution would 
be very helpful.

Please provide any additional information below.

Original issue reported on code.google.com by vj...@io-works.com on 17 Aug 2014 at 10:13

GoogleCodeExporter commented 8 years ago
This is question for the mailing list. Please direct it there.

Original comment by noelgrandin on 18 Aug 2014 at 6:33

GoogleCodeExporter commented 8 years ago
*Adding the solution here, for referrence*
You can use ARRAY_GET(x,1) to retrieve individual values from an ARRAY. There 
is currently no way to retrieve multiple 
values. 

You will need to do something like 
SELECT ARRAY_GET(x,1) || ',' || ARRAY_GET(x,2) 

Original comment by vj...@io-works.com on 19 Aug 2014 at 4:36