how to let dbeaver to highlight sql error for easier development process - dbeaver

I had a sql that had some error. Although the error says
SQL Error [42601]: ERROR: syntax error at or near "from"
Position: 420
. However, it seems dbeaver didn't highlight exactly where the error is. It tells me it is position 420, but i don't know where is position 420 intuitively....
Is it possible to let DBeaver to highlight error for me.
PS: I could identify the error by eyeballing this time... but other times seem difficult...

DBeaver puts the cursor to the place of error in your query in SQL Editor. For different types of databases. For example, for PostgreSQL, whose error message you, apparently, used in your topic.

Related

Aginity SQL error message shows wrong character

When I make a query in Aginity with an error in it, it gives a notification like
ERROR: '[My SQL here]'
error
^ found "INSERT" (at char 2292) expecting `SELECT' or `'(''
If I click on the location of that error in my SQL, it's actually at Position: 3934. I think Aginity is disregarding the whitespace when it tries to say where the error is. Is there a way to make it show the position in the builder?
It's not Aginity that does this, it's somewhere up the software stack (I suspect it's on the actual Netezza itself).
What I do (and this is a POOR solution) is to remove the whitespace myself.
Since I use Unix (mostly) and Vim this is a little easier than in Aginity.
It really is a PITA, and IBM should proved a better solution (one would be to kick back the SQL statement as run with all the whitespace removed).

postgresql syntax error and then the cursor is open

This error 'the cursor is open' took me some hours to resolve, so I submit here the explanation in order to propose a solution for people experiencing the same problem.
Problem description : trying to get data from postgreSQL through standard function SQLEXEC raised "Syntax Error", while the same query runs correctly on PGAdmin. Morecover, subsequent queries systematically raised "The cursor is open" (each time being necessary to kill Postgres process AND to reinit the VFP connexion).
Conditions: Postgres 9.3.3, Windows XP SP2, PostgreSQL ODBC Driver(UNICODE) version 9.02.01.00, Visual FoxPro 9 SP1
Solution: SQLExec 3rd parameter should not contain a dot ("."). For example, the command SQLExec(1, 'Select 1', '.F.') raises the problem, when SQLExec(1, 'Select 1', 'F') does not.
In my case '.F.' value was generated programmatically, which made the diagnosis difficult.
That is not a VFP error bur programmer's error. The 3rd parameter is a cursor name for the result and as said in the documentation a cursor name cannot have dot. OTOH 'F' is a valid cursor name.
As per the syntax error, very likely you were trying to pass a long sql string literal over 255 characters but can't be sure as we don't see your code. In VFP it is also documented that character literals cannot exceed 255 in length.

simple mysqli NOW() syntax error

sorry, I really don't see it.
I have a mysqli syntax like this:
"UPDATE table
SET
used='1',
ip='".mysqli_real_escape_string($connection,$_SERVER['REMOTE_ADDR'])."',
when=NOW()
WHERE
uid='x3'"
This is my error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
when=NOW()
WHERE
uid='x3'' at line 6
WHEN is a reserved word in MySQL. If you wish to use it as a column name you must surround it in backticks.
In other words, replace
when=NOW()
with
`when`=NOW()

PostgreSQL error: syntax error at or near "exists"

I have a very simple query:
DROP TYPE IF EXISTS abc;
When run on my local machine, all good. When run on my production machine, it returns:
ERROR: syntax error at or near "EXISTS" at character 14
I have tried typing it manually rather than copying to make sure there is no hidden character somewhere, but I can not figure out how this can given an error at one place but not at another.
Check the versions that you're using, for both local and production.
The if exists clause was only added to drop type in 8.2.
And, before anyone questions why it complains about the exists rather than the if, it's because the statement:
drop type if
is perfectly valid up to that point, as an attempt to drop the if type. It's only the exists after that which makes the syntax bad.

PostgreSQL syntax error eof caused commit

We are working on merging individual files into a group PostgreSQL database. The files have all been working perfectly fine on their own and when we have combined we have run them with no problems. It started to hang on the creation of one trigger, so we commented the trigger out. The next time we ran the merge file we got the following error:
ERROR: Syntax error at end of input
LINE 181: --$$ LANGUAGE plpgsql
Following this error there were subsequent syntax errors and then to our horror we found the following in our log file:
ERROR: Syntax error at end of input
LINE 181: --$$ LANGUAGE plpgsql
COMMIT
We had tests in this file that contained test data that was NOT supposed to be entered into the database, corrupting who knows how much of the data in our database. We have looked through every file included and there is no COMMIT anywhere!
Has anyone ever run into something similar? Is there any reason why an error in parsing would ever cause a commit?
If you don't have a BEGIN statement, then the PostgreSQL connection is in "autocommit" mode, committing each change after the statement is run. Since you're incorrectly commenting your code, I'd say you've commented the BEGIN statement earlier in the code. But I can't be sure because you did not provide any of your SQL.
Note that the syntax:
--$$
does not comment out the end of function $$. What it means is empty comment as the last thing inside a string. It might help you if you read the line as:
--
$$
That is why you're getting a parse error on a "commented" line. If it was actually commented, PostgreSQL would not parse it. $$ is a quote operator enclosing SQL code, and is just a convenience syntax against using ''s for quoting (which would mean you have to double-quote each quote inside the quoted SQL). What you think was a commented out line was actually just a piece of a string ending with two hyphens.
On a general note: You should use commenting only for adding descriptions to the code and not disabling sections of code. Use version control if you need to have access to older versions of the code.
Edit: Clarified explanation on quoted strings. Hope this makes more sense now.