-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Title: Tab characters are stripped when executing code via "Run in SQLcl" causing syntax errors
Description:
When executing SQL/PL-SQL code that contains tab characters (not spaces) using the "Run in SQLcl" execution option in the Oracle SQL Developer VS Code extension, all tab characters are completely removed without being replaced with spaces. This causes lines to concatenate incorrectly, resulting in syntax errors.
Impact:
- Code that executes correctly in other SQL clients fails with syntax errors
- Developers who use tabs for indentation cannot use the "Run in SQLcl" feature
- Error messages are misleading (reports invalid keywords like "ANDIDENTITY_COLUMN")
Steps to Reproduce:
- Open Oracle SQL Developer Extension for VS Code
- Create a new SQL file or open SQL Worksheet
- Paste the following PL/SQL code (ensure tabs are preserved):
declare
cursor tc is
select tc.*
from user_tab_columns tc, user_tables t
where 1=1
and tc.table_name=t.table_name
and IDENTITY_COLUMN='YES'
and default_on_null='YES'
order by tc.table_name,tc.column_id;
curr_max number;
stmt varchar2(2000);
begin
dbms_output.enable(null);
for r_tc in tc loop
stmt := 'select nvl(max('||r_tc.column_name||'),0)+1 cnt from '||r_tc.table_name||' t';
execute IMMEDIATE stmt into curr_max;
stmt := 'alter table '||r_tc.table_name||' modify ('||r_tc.column_name||
' GENERATED BY DEFAULT ON NULL AS IDENTITY INCREMENT BY 1 START WITH '||curr_max||' MINVALUE 1 MAXVALUE 9999999999999999999999999999 NOCYCLE ORDER NOCACHE'||
')';
dbms_output.put_line(rpad(r_tc.table_name,35,' ')||': '||stmt);
execute IMMEDIATE stmt;
end loop;
end;
/IMPORTANT: Lines 6-8 must have TAB characters (not spaces) at the beginning:
and tc.table_name=t.table_name
and IDENTITY_COLUMN='YES'
and default_on_null='YES'
- Attach a database connection
- Click the "Run in SQLcl" button (the button with the terminal icon)
- Observe the error
Expected Result:
The code should execute successfully. Tabs should be either:
- Preserved as tab characters, OR
- Converted to equivalent spaces (e.g., 1 tab = 4 spaces)
Actual Result:
The code fails with syntax error:
ORA-06550: line 6, column 32:
PL/SQL: ORA-03049: SQL keyword 'ANDIDENTITY_COLUMN' is not syntactically valid following '...tc.table_name=t.table_name
'
Root Cause:
The tabs are being completely stripped, causing:
Original code with tabs:
where 1=1
and tc.table_name=t.table_name
and IDENTITY_COLUMN='YES'What SQLcl receives (tabs removed):
where 1=1
andtc.table_name=t.table_name
andIDENTITY_COLUMN='YES'Notice how "and" and the next word are concatenated into "andIDENTITY_COLUMN" because the tab was removed entirely.
Environment:
- Extension Name: Oracle SQL Developer Extension for VSCode
- Extension Version: [FILL IN YOUR VERSION]
- VS Code Version: [FILL IN YOUR VERSION]
- Operating System: macOS [FILL IN YOUR VERSION]
- Oracle Database Version: Oracle Autonomous Database 19c
- Execution Method: "Run in SQLcl" button
Workaround:
Convert all tabs to spaces before executing:
- Select all text (Cmd+A / Ctrl+A)
- Open Command Palette (Cmd+Shift+P / Ctrl+Shift+P)
- Run: "Convert Indentation to Spaces"
- Execute the code
Or configure VS Code to use spaces by default:
{
"[sql]": {
"editor.insertSpaces": true,
"editor.tabSize": 4
}
}Additional Notes:
- This issue does NOT occur when using "Run Statement" or "Run Script" buttons
- The issue is specific to the "Run in SQLcl" execution option
- The desktop version of SQL Developer handles tabs correctly
- Other SQL editors (SQL*Plus, SQLcl command line) preserve tabs correctly
Suggested Fix:
The extension should convert tabs to spaces before sending code to SQLcl, similar to:
// Current (incorrect):
const code = editorContent.replace(/\t/g, ''); // Removes tabs
// Should be:
const code = editorContent.replace(/\t/g, ' '); // Replace with spaces