Sublime Forum

SQL syntax treat # as comment

#1

Hello guys!

I am using Sublime text 3.0 build 3143.
After writing select like this:

  1. CREATE TABLE #Yaks (
  2. YakID int,
  3. YakName char(30) )

And setting syntax to SQL everything in line 1 after # is treated as comment (greyed out).
Single line comments in SQL starts with ‘–’
Multiline comments /* */ works perfectly.
Is this a bug or am i missing something?

0 Likes

#2

it’s a bug in the sense that the SQL syntax currently only really supports MySQL syntax as opposed to ANSI or other flavors, but my understanding is that there are plans to add separate SQL dialects soon :tm:

0 Likes

#3

Did you try this package?

I am not a SQL expert, but pasting your lines into ST and applying Oracle PL/SQL syntax seems to work properly.

Comment lines starting with -- are greyed out, but your # not.

The also provided syntax Oracle SQL doesn’t work at all - no idea why.

0 Likes

#4

The Oracle SQL syntax really only highlights queries. I’m not sure it’s a useful distinction at this point, and I might remove it.

0 Likes

#5

It didn’t highlight anything in my case not even a simple SELECT * FROM. But I honestly didn’t check that any further.

Btw.: Important thing might be to make this syntax importable by others easily. Such as with the regex patterns in default package.

0 Likes

#6

I have removed error from my sql error.

0 Likes

#7

As a work around I extracted Sublime’s default SQL.sublime-package and added it to my user packages and commented out the section with the number sign entry in the syntax file. I changing the name to JSQL and it worked out great.

Now, I’d like to edit the autocomplete settings for this package and I have no idea where to start. I want the autocomplete suggestions to include the # if it part of a field name. For example, I have a field named “OSSEQ#” yet the autocomplete option is “OSSEQ”.

I’ve tried Oracle package suggested by @deathaxe. Using the Oracle/Oracle SQL syntax setting the autocomplete works but the syntax highlighting is incomplete. Oracle/Oracle PL/SQL has much better syntax highlighting but autocomplete no longer includes '#'s if they’re part of variable names.

I inherited a DB2 database from the dark ages (System 36) with a lot of custom programs spread across CL and several versions ILE RPG so I’m stuck with the naming schemes.

0 Likes