Page 1 of 1

DBeaver throws SQL error when query contains empty lines

PostPosted: Wed Aug 22, 2012 5:25 pm
by carlosjrcabello

Re: DBeaver throws SQL error when query contains empty lines

PostPosted: Thu Aug 23, 2012 7:49 am
by Serge
Actually it is not a bug.
DBeaver has two modes of SQL execution: statement (CTRL+Enter) and script (ALT+X).
In statement mode it extracts current statement (it is statement where cursor is positioned and it is delimited by empty lines or by ";" symbol). It allows you to have many SQL statements in a single SQL editor and execute any of them at any time. It is very convinient if many cases. Empty line as statement delimiter is very native and visual way to structurize text.
Also you may select any part of SQL text and press CTRL+Enter - dbeaver will execute only selected text.

In script mode dbeaver executes entire SQL script. It will split script on statements using ";" symbol (empty lines have no meaning in this mode) and then execute them one by one.

So, if you want to execute single statement which contains empty line you have to select this statement and press CTRL+Enter.

Probably we can somehow improve SQL execution. But at the moment I don't have any good ideas about it.

Re: DBeaver throws SQL error when query contains empty lines

PostPosted: Thu Aug 23, 2012 1:04 pm
by carlosjrcabello

Re: DBeaver throws SQL error when query contains empty lines

PostPosted: Thu Aug 23, 2012 3:18 pm
by Serge
Good evening ;)

The comments issue looks like a bug. Do you use Oracle database?

Maybe the problem is in linefeed characters (and in difference between unix/windows).
Or maybe the problem is in driver. Single line comments should work properly in any place of SQL statement. But probably some database vendors doesn't support it.

I'll investigate this issue..
Thanks for report!

Re: DBeaver throws SQL error when query contains empty lines

PostPosted: Thu Aug 23, 2012 4:46 pm
by carlosjrcabello
I'm forget your timezone :D ...

Ok, i'm using this version:
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
And referring at driver version, i'm let DBeaver download from yours repositories:
mysql-connector-5.1.13.bin.jar

Re: DBeaver throws SQL error when query contains empty lines

PostPosted: Thu Aug 23, 2012 4:53 pm
by fallingdown
Whenever I'm writing a somewhat large and complicated query I like to separate the sections out with blank lines for readability. I'm pretty judicious user of the semicolon delimiter. It would be a nice feature to be able to disable the treatment of a blank line as a statement delimiter.

Re: DBeaver throws SQL error when query contains empty lines

PostPosted: Thu Aug 23, 2012 5:07 pm
by carlosjrcabello

Re: DBeaver throws SQL error when query contains empty lines

PostPosted: Sun Aug 26, 2012 1:22 pm
by Serge
Ok, I think that adding of one more configuration parameter is a good colution. One problem that it is not obvious for user. Most people won't even try to find such tricky parameter in preferences.
But anyway I'll add it.

Re: DBeaver throws SQL error when query contains empty lines

PostPosted: Mon Aug 27, 2012 3:22 pm
by fallingdown
Thanks! Obviously, I would probably leave the treatment of empty lines as statement delimiters as the default. But you're correct, most users probably will not try to find such a parameter, until they decide they want it. Then they go looking for it (which is what I did ;) ).

Thanks again!