Skip to Main Content

SQL Developer for VS Code

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Export query result fails If the second to last line is a comment

user5841680Feb 1 2024

I noticed that when the second to last line is a comment, the query will run fine, but then the query result export (to CSV) will fail.

I'm still new-ish to SQL, and I noticed that in Oracle SQL Developer Extension for VS Code I will get a syntax error unless the last line is a semi-colon/I end my query with a semi-colon. I previously did not do this when using Oracle SQL Developer.

Consider this:

SELECT * 
FROM V$VERSION 
--comment 
;

Here's the error message:

Error starting at line : 4 in command -
SELECT *
FROM V$VERSION
--comment;
SET SQLFORMAT DEFAULT
SET FEEDBACK ON
Error at Command Line : 7 Column : 1
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "unexpected keyword at or near %s"
*Cause: An unexpected keyword was encountered in the SQL statement at
or near the position printed in the error message.
One of the following occurred:
1. You had a typo in your SQL statement.
2. Unsupported syntax was encountered for a clause in the
statement.
3. An unsupported clause was encountered in the statement.
4. A string was terminated prematurely leading to the rest
of the string to be interpreted as keywords. For example, an
apostrophe in the string may be causing it to
end prematurely.
*Action: Take the action that corresponds with the Cause
1. Check that your SQL statement has no typos.
2. Check Oracle Database documentation to find the
correct syntax for the clause and update the problematic
clause appropriately.
3. Check Oracle Database documentation to find the correct
syntax for the statement and remove the unsupported clause.
4. Enter two single quotes instead of one to represent an
apostrophe within a string.
*Params: 1) keyword_value
keyword near the keyword causing the error. The keyword value
may be truncated for readability if it is too long.

More Details :
https://docs.oracle.com/error-help/db/ora-00933/

However, this will export fine:

SELECT * 
FROM V$VERSION 
;

My actual query is more like this, where I will denote the beginning and end of blocks of code I may comment in/out later.

SELECT
	TABLE_ONE.SYSTEM_ID
	,TABLE_ONE.SYSTEM_NAME
	,TABLE_TWO.RULE_ID
	--,TABLE_TWO.DISPLAY_NAME
	,TABLE_TWO.DESCRIPTION

FROM 
TABLE_ONE
	LEFT OUTER JOIN TABLE_TWO
		ON TABLE_TWO.SYSTEM_ID=TABLE_ONE.SYSTEM_ID
		
WHERE

/*
	--list A
	TABLE_ONE.SYSTEM_ID IN (
		2201
		,2202
		,2203
	)
	--list A
*/

	--list B
	TABLE_ONE.SYSTEM_ID IN (
		2204
		,2205
		,2206
	)
	--list B
;

I'm using:
VSCode 1.86.0
Oracle SQL Developer Extension for VSCode v23.4.0

Thanks to the developers on this! It's great to be able to write using VSCode!!

This post has been answered by thatJeffSmith-Oracle on Feb 1 2024
Jump to Answer

Comments

Post Details

Added on Feb 1 2024
1 comment
624 views