The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.
Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!
Unclear error location
I'm having trouble with Vertica's description of errors. It doesn't tell me what line it is on, so the errors can often be very hard to find. We often get something like this
`Query execution failed
SQL Error  : [Vertica]VJDBC ERROR: Syntax error at or near ","`
My code is full of commas! Is there any way to get the row number of the error?
We access our Vertica DB through Dbeaver and Redash.
Check the DC_ERRORS system table.
I can see that the error is in position 10 of the SQL I ran!
Vertica Quick Tip:
I saw that Vertica Quick Tip before, but it is very inconvenient to have to find my error in another table. Is there any way to get that information into a SQL client like Dbeaver or Redeash? I've attached a picture of the error popup I get. The details button is already expanded.
Note that in my example using vsql, the error message included the text "at character 10". Unfortunately that info is being omitted in DBeaver, but I am not sure why. This seems to be the case with any SQL client that uses the Vertica JDBC driver.
I will check around to see if I can figure out why that's the case and will create a feature request to modify that behavior if the issue is on our side.
In the meantime, I think the checking the Vertica system tables is your only option to find the error position.
It's not to difficult if you run the query against the DC_ERRORS table immediately after you get the error:
Maybe create a view to show the last error in you current session?
It seems this is a bug in the JDBC driver Vertica in that it doesn't deliver the complete error message . Using 3 separate SQL editors, the error messages truncate after the first line, stopping the user from seeing the line #/context.
It is possible to get the position using the Vertica JDBC driver but the application you use needs to leverage it.
Here's how to get all information about latest Vertica error on your current connection:
Using Jim's sample query (SELECT 1,,2) would show the following:
It's unfortunate for the driver to expect the client do the linenumber lift, because DBeaver, DBVisualizer, and SQLDbx all exhibit the same behavior. The driver seems the odd man out here. Requires having a workaround of having a separate terminal with vsql open just for the purposes of copying/pasting SQL and showing me the line number.
1) Jim's example to find the exact place for the syntax error, works nice in DBeaver as follows:
SELECT time, log_message, cursor_position FROM dc_errors WHERE session_id = current_session() ORDER BY time DESC LIMIT 1;
2) CTRL+ALT+SHIFT+X Execute queries in DBeaver simultaneously, showing results in separate tabs.
3) Click on the Skip button and get the 2nd query result in a separate DBeaver tab:
Syntax error at or near "," 10
Hi mosheg, I'm not seeing how the example you gave gives the user any useful information about where the error is. In vsql, at least the line number is given, along with a caret pointing to the position in the line:
The key information is in the second and third lines lines. The character position of an error is not useful in a in a 200-line SQL query. Even simply the the line # would be extremely helpful.
Imagine compiling a C++ program and being told "syntax error at character 4000". Simply not useful.