1 {-------------------------------------------------------------------------------
2 The contents of this file are subject to the Mozilla Public License
3 Version 1.1 (the "License"); you may not use this file except in compliance
4 with the License. You may obtain a copy of the License at
5 http://www.mozilla.org/MPL/
6 
7 Software distributed under the License is distributed on an "AS IS" basis,
8 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9 the specific language governing rights and limitations under the License.
10 
11 The Original Code is: SynHighlighterSQL.pas, released 2000-04-21.
12 The Original Code is based on the wmSQLSyn.pas and wmSybaseSyn.pas files from
13 the mwEdit component suite by Martin Waldenburg and other developers, the
14 Initial Author of these files is Willo van der Merwe. Initial Author of
15 SynHighlighterSQL.pas is Michael Hieke.
16 Portions created by Willo van der Merwe are Copyright 1999 Willo van der Merwe.
17 Portions created by Michael Hieke are Copyright 2000 Michael Hieke.
18 All Rights Reserved.
19 
20 Contributors to the SynEdit and mwEdit projects are listed in the
21 Contributors.txt file.
22 
23 Alternatively, the contents of this file may be used under the terms of the
24 GNU General Public License Version 2 or later (the "GPL"), in which case
25 the provisions of the GPL are applicable instead of those above.
26 If you wish to allow use of your version of this file only under the terms
27 of the GPL and not to allow others to use your version of this file
28 under the MPL, indicate your decision by deleting the provisions above and
29 replace them with the notice and other provisions required by the GPL.
30 If you do not delete the provisions above, a recipient may use your version
31 of this file under either the MPL or the GPL.
32 
33 $Id: synhighlightersql.pas 46388 2014-09-30 23:57:55Z martin $
34 
35 You may retrieve the latest version of this file at the SynEdit home page,
36 located at http://SynEdit.SourceForge.net
37 
38 Known Issues:
39 -------------------------------------------------------------------------------}
40 {
41 @abstract(SQL highlighter for SynEdit with support for different dialects.)
42 @author(Michael Hieke)
43 @created(2000-04-21)
44 @lastmod(2000-11-16)
45 The SynHighlighterSQL implements a highlighter for SQL for the SynEdit projects.
46 Different SQL dialects can be selected via the Dialect property.
47 }
48 unit SynHighlighterSQL;
49 
50 {$I SynEdit.inc}
51 
52 interface
53 
54 uses
55   SysUtils, Classes,
56   LCLIntf, LCLType,
57   Controls, Graphics,
58   SynEditTypes, SynEditHighlighter,
59   SynHighlighterHashEntries;
60 
61 type
62   TtkTokenKind = (tkComment, tkDatatype, tkDefaultPackage, tkException,         // DJLP 2000-08-11
tkIdentifiernull63     tkFunction, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace, tkPLSQL,        // DJLP 2000-08-11
64     tkSQLPlus, tkString, tkSymbol, tkTableName, tkUnknown, tkVariable);         // DJLP 2000-08-11
65 
66   TRangeState = (rsUnknown, rsComment, rsString);
67 
68   TProcTableProc = procedure of object;
69 
70   TSQLDialect = (sqlStandard, sqlInterbase6, sqlMSSQL7, sqlMySQL, sqlOracle,
71     sqlSybase, sqlIngres, sqlMSSQL2K, sqlPostgres, sqlSQLite);                                           // JJV 2000-11-16
72 
73 type
74   PIdentifierTable = ^TIdentifierTable;
75   TIdentifierTable = array[Char] of ByteBool;
76 
77   PHashTable = ^THashTable;
78   THashTable = array[Char] of Integer;
79 
80 type
81   TSynSQLSyn = class(TSynCustomHighlighter)
82   private
83     fRange: TRangeState;
84     fLine: PChar;
85     fLineNumber: Integer;
86     fProcTable: array[#0..#255] of TProcTableProc;
87     Run: LongInt;
88     fStringLen: Integer;
89     fToIdent: PChar;
90     fTokenPos: Integer;
91     fTokenID: TtkTokenKind;
92     fKeywords: TSynHashEntryList;
93     fTableNames: TStrings;
94     fDialect: TSQLDialect;
95     fCommentAttri: TSynHighlighterAttributes;
96     fDataTypeAttri: TSynHighlighterAttributes;
97     fDefaultPackageAttri: TSynHighlighterAttributes;                            // DJLP 2000-08-11
98     fExceptionAttri: TSynHighlighterAttributes;
99     fFunctionAttri: TSynHighlighterAttributes;
100     fIdentifierAttri: TSynHighlighterAttributes;
101     fKeyAttri: TSynHighlighterAttributes;
102     fNumberAttri: TSynHighlighterAttributes;
103     fPLSQLAttri: TSynHighlighterAttributes;                                     // DJLP 2000-08-11
104     fSpaceAttri: TSynHighlighterAttributes;
105     fSQLPlusAttri: TSynHighlighterAttributes;                                   // DJLP 2000-09-05
106     fStringAttri: TSynHighlighterAttributes;
107     fSymbolAttri: TSynHighlighterAttributes;
108     fTableNameAttri: TSynHighlighterAttributes;
109     fVariableAttri: TSynHighlighterAttributes;
110     fIdentifiersPtr: PIdentifierTable;
111     fmHashTablePtr: PHashTable;
KeyHashnull112     function KeyHash(ToHash: PChar): Integer;
KeyCompnull113     function KeyComp(const aKey: string): Boolean;
114     procedure AndSymbolProc;
115     procedure AsciiCharProc;
116     procedure CRProc;
117     procedure EqualProc;
118     procedure GreaterProc;
119     procedure IdentProc;
120     procedure LFProc;
121     procedure LowerProc;
122     procedure MinusProc;
123     procedure NullProc;
124     procedure NumberProc;
125     procedure OrSymbolProc;
126     procedure PlusProc;
127     procedure SlashProc;
128     procedure SpaceProc;
129     procedure StringProc;
130     procedure SymbolProc;
131     procedure SymbolAssignProc;
132     procedure VariableProc;
133     procedure UnknownProc;
IdentKindnull134     function IdentKind(MayBe: PChar): TtkTokenKind;
135     procedure MakeMethodTables;
136     procedure AnsiCProc;
137     procedure DoAddKeyword(AKeyword: string; AKind: integer);
138     procedure SetDialect(Value: TSQLDialect);
139     procedure SetTableNames(const Value: TStrings);
140     procedure TableNamesChanged(Sender: TObject);
141     procedure InitializeKeywordLists;
142     procedure PutTableNamesInKeywordList;
143   protected
GetIdentCharsnull144     function GetIdentChars: TSynIdentChars; override;
GetSampleSourcenull145     function GetSampleSource : String; override;
146   public
GetLanguageNamenull147     class function GetLanguageName: string; override;
148   public
149     constructor Create(AOwner: TComponent); override;
150     destructor Destroy; override;
151     procedure Assign(Source: TPersistent); override;
GetDefaultAttributenull152     function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
153       override;
GetEolnull154     function GetEol: Boolean; override;
GetRangenull155     function GetRange: Pointer; override;
GetTokennull156     function GetToken: string; override;
157     procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override;
158 
GetTokenAttributenull159     function GetTokenAttribute: TSynHighlighterAttributes; override;
GetTokenIDnull160     function GetTokenID: TtkTokenKind;
GetTokenKindnull161     function GetTokenKind: integer; override;
GetTokenPosnull162     function GetTokenPos: Integer; override;
IsKeywordnull163     function IsKeyword(const AKeyword: string): boolean; override;              // DJLP 2000-08-09
164     procedure Next; override;
165     procedure ResetRange; override;
166     procedure SetLine(const NewValue: string; LineNumber: Integer); override;
167     procedure SetRange(Value: Pointer); override;
168   published
169     property CommentAttri: TSynHighlighterAttributes read fCommentAttri
170       write fCommentAttri;
171     property DataTypeAttri: TSynHighlighterAttributes read fDataTypeAttri
172       write fDataTypeAttri;
173     property DefaultPackageAttri: TSynHighlighterAttributes                     // DJLP 2000-08-11
174       read fDefaultPackageAttri write fDefaultPackageAttri;
175     property ExceptionAttri: TSynHighlighterAttributes read fExceptionAttri
176       write fExceptionAttri;
177     property FunctionAttri: TSynHighlighterAttributes read fFunctionAttri
178       write fFunctionAttri;
179     property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri
180       write fIdentifierAttri;
181     property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri;
182     property NumberAttri: TSynHighlighterAttributes read fNumberAttri
183       write fNumberAttri;
184     property PLSQLAttri: TSynHighlighterAttributes read fPLSQLAttri             // DJLP 2000-08-11
185       write fPLSQLAttri;
186     property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri
187       write fSpaceAttri;
188     property SQLPlusAttri: TSynHighlighterAttributes read fSQLPlusAttri         // DJLP 2000-09-05
189       write fSQLPlusAttri;
190     property StringAttri: TSynHighlighterAttributes read fStringAttri
191       write fStringAttri;
192     property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri
193       write fSymbolAttri;
194     property TableNameAttri: TSynHighlighterAttributes read fTableNameAttri
195       write fTableNameAttri;
196     property TableNames: TStrings read fTableNames write SetTableNames;
197     property VariableAttri: TSynHighlighterAttributes read fVariableAttri
198       write fVariableAttri;
199     property SQLDialect: TSQLDialect read fDialect write SetDialect;
200   end;
201 
202 implementation
203 
204 uses
205   SynEditStrConst;
206 
207 var
208   Identifiers: TIdentifierTable;
209   mHashTable: THashTable;
210 
211   IdentifiersMSSQL7: TIdentifierTable;
212   mHashTableMSSQL7: THashTable;
213 
214 const
215   //---SQLite keywords------------------------------------------------------------
216   SQLiteKW: string =
217     'abort,action,add,after,all,alter,analyze,and,as,asc,attach,autoincrement,' +
218     'before,begin,between,by,cascade,case,cast,check,collate,column,commit,' +
219     'conflict,constraint,create,cross,current_date,current_time,current_timestamp,' +
220     'database,default,deferrable,deferred,delete,desc,detach,distinct,drop,each,else,' +
221     'end,escape,except,exclusive,exists,explain,fail,for,foreign,from,full,glob,group,' +
222     'having,if,ignore,immediate,in,index,indexed,initially,inner,insert,instead,intersect,' +
223     'into,is,isnull,join,key,left,like,limit,match,natural,no,not,notnull,null,of,offset,on,' +
224     'or,order,outer,plan,pragma,primary,query,raise,references,regexp,reindex,release,rename,' +
225     'replace,restrict,right,rollback,row,savepoint,select,set,table,temp,temporary,then,to,' +
226     'transaction,trigger,union,unique,update,using,vacuum,values,view,virtual,when,where';
227 
228   SQLiteTypes: string =
229     'int,integer,tinyint,smallint,mediumint,bigint,int2,int8,character,varchar,' +
230     'nchar,,nvarchar,text,clob,blob,real,double,float,numeric,decimal,boolean,' +
231     'date,datetime';
232 
233   SQLiteFunctions: string =
234     'abs,avg,changes,coalesce,count,group_concat,hex,ifnull,' +
235     'julianday,last_insert_rowid,length,load_extension,lower,ltrim,max,min,' +
236     'nullif,quote,random,randomblob,round,rtrim,soundex,sqlite_compileoption_get,' +
237     'sqlite_compileoption_used,sqlite_source_id,sqlite_version,strftim,substr,sum,time,' +
238     'total,total_changes,trim,typeof,upper,zeroblob';
239 
240 //---"Standard" (ANSI SQL keywords (Version 1, 2 and 3) (www.sql.org)---------
241   StandardKW: string =
242     'absolute,action,active,actor,add,after,alias,all,allocate,alter,' +
243     'and,any,are,as,asc,ascending,assertion,async,at,attributes,auto,' +
244     'base_name,before,begin,between,bit,bit_length,boolean,both,breadth,by,' +
245     'cache,call,cascade,cascaded,case,cast,catalog,char_length,' +
246     'character_length,check,coalesce,collate,collation,column,commit,' +
247     'committed,completion,computed,conditional,connect,connection,constraint,' +
248     'constraints,containing,convert,corresponding,count,create,cross,current,' +
249     'current_date,current_path,current_time,current_timestamp,current_user,' +
250     'cursor,cycle,data,database,date,day,deallocate,debug,declare,default,' +
251     'deferrable,deferred,delete,depth,desc,descending,describe,descriptor,' +
252     'destroy,diagnostics,dictionary,disconnect,distinct,do,domain,' +
253     'drop,each,element,else,elseif,end,end-exec,entry_point,equals,escape,' +
254     'except,exception,execute,exists,exit,external,extract,factor,false,' +
255     'filter,first,for,foreign,from,full,function,general,generator,get,' +
256     'global,grant,group,having,hold,hour,identity,if,ignore,immediate,in,' +
257     'inactive,index,initially,inner,input,insensitive,insert,instead,' +
258     'intersect,interval,into,is,isolation,join,key,last,leading,leave,left,' +
259     'less,level,like,limit,list,local,loop,lower,match,merge,minute,modify,' +
260     'month,names,national,natural,nchar,new,new_table,next,no,none,not,null,' +
261     'nullif,object,octet_length,of,off,old,old_table,on,only,operation,' +
262     'operator,operators,or,order,others,outer,output,overlaps,pad,' +
263     'parameter,parameters,partial,password,path,pendant,plan,position,' +
264     'postfix,prefix,preorder,prepare,preserve,primary,prior,private,' +
265     'privileges,procedure,protected,read,recursive,ref,referencing,relative,' +
266     'replace,resignal,restrict,retain,return,returns,revoke,right,role,' +
267     'rollback,routine,row,rows,savepoint,schema,scroll,search,second,select,' +
268     'sensitive,sequence,session,session_user,set,shadow,shared,signal,' +
269     'similar,size,snapshot,some,space,sqlexception,sqlstate,sqlwarning,start,' +
270     'state,structure,substring,suspend,symbol,system_user,table,temporary,' +
271     'term,test,then,there,time,timestamp,timezone_hour,timezone_minute,to,' +
272     'trailing,transaction,translate,translation,trigger,trim,true,tuple,type,' +
273     'uncommitted,under,union,unique,unknown,update,upper,usage,user,using,' +
274     'value,varchar,variable,varying,view,virtual,visible,wait,when,where,' +
275     'while,with,without,work,write,year,zone';
276 
277 //---Sybase keywords------------------------------------------------------------
278   SybaseKW: string =
279     'absolute,action,add,after,alias,all,allocate,alter,and,any,are,' +
280     'arith_overflow,as,asc,assertion,async,at,authorization,avg,before,begin,' +
281     'between,bit,bit_length,boolean,both,breadth,break,browse,bulk,by,call,' +
282     'cascade,cascaded,case,cast,catalog,char,char_convert,char_length,' +
283     'character,character_length,check,checkpoint,close,clustered,coalesce,' +
284     'collate,collation,column,commit,completion,compute,confirm,' +
285     'connect,connection,constraint,constraints,continue,controlrow,convert,' +
286     'corresponding,count,create,cross,current,current_date,current_time,' +
287     'current_timestamp,current_user,cursor,cycle,data,database,date,day,dbcc,' +
288     'deallocate,dec,decimal,declare,default,deferrable,deferred,delete,depth,' +
289     'desc,describe,descriptor,diagnostics,dictionary,dis,disconnect,distinct,' +
290     'domain,double,drop,dummy,dump,each,else,elseif,en,end,endtran,equals,' +
291     'errlvl,errordata,errorexit,escape,except,exception,exclusive,exec,' +
292     'execute,exists,exit,exp_row_size,external,extract,false,fetch,' +
293     'fillfactor,first,float,for,foreign,found,from,full,general,get,global,' +
294     'go,goto,grant,group,having,holdlock,hour,identity,identity_gap,' +
295     'identity_insert,identity_start,if,ignore,immediate,in,index,indicator,' +
296     'initially,inner,input,insensitive,insert,install,int,integer,intersect,' +
297     'interval,into,is,isolation,jar,join,key,kill,language,last,leading,' +
298     'leave,left,less,level,like,limit,lineno,load,local,lock,loop,lower,' +
299     'match,max,max_rows_per_page,min,minute,mirror,mirrorexit,modify,module,' +
300     'month,names,national,natural,nchar,new,next,no,noholdlock,nonclustered,' +
301     'none,not,null,nullif,numeric,numeric_truncation,object,' +
302     'octet_length,of,off,offsets,oid,old,on,once,online,only,open,operation,' +
303     'operators,option,or,order,others,outer,output,over,overlaps,pad,' +
304     'parameters,partial,partition,pendant,perm,permanent,plan,position,' +
305     'precision,preorder,prepare,preserve,primary,print,prior,private,' +
306     'privileges,proc,procedure,processexit,protected,proxy_table,public,' +
307     'quiesce,raiserror,read,readpast,readtext,real,reconfigure,recursive,' +
308     'ref,reference,referencing,relative,remove,reorg,replace,replication,' +
309     'reservepagegap,resignal,restrict,return,returns,revoke,right,role,' +
310     'rollback,routine,row,rowcount,rows,rule,save,savepoint,schema,scroll,' +
311     'search,second,section,select,sensitive,sequence,session_user,set,' +
312     'setuser,shared,shutdown,signal,similar,size,smallint,some,space,sql,' +
313     'sqlcode,sqlerror,sqlexception,sqlstate,statistics,stripe,structure,' +
314     'substring,sum,syb_identity,syb_restree,system_user,table,temp,temporary,' +
315     'test,textsize,then,there,time,timestamp,timezone_hour,timezone_minute,' +
316     'to,trailing,tran,transaction,translate,translation,trigger,trim,true,' +
317     'truncate,tsequal,type,under,union,unique,unknown,unpartition,update,' +
318     'upper,usage,use,user,user_option,using,value,values,varchar,variable,' +
319     'varying,view,virtual,visible,wait,waitfor,when,whenever,where,while,' +
320     'with,without,work,write,writetext,year,zone';
321 
322 //---Oracle---------------------------------------------------------------------
323   // Oracle SQL keywords
324   OracleKW: string =
325     'ACCESS,ACCESSED,ACCOUNT,ACTIVATE,ACTIVE_INSTANCE_COUNT,ADD,ADMIN,ADVISE,' +
326     'AGENT,ALL,ALLOCATE,ALTER,ANALYZE,ANCILLARY,AND,ANY,AQ_TM_PROCESSES,' +
327     'ARCHIVE_LAG_TARGET,ARCHIVELOG,AS,ASC,ASSOCIATE,ATTRIBUTES,AUDIT,' +
328     'AUDIT_FILE_DEST,AUDIT_SYS_OPERATIONS,AUDIT_TRAIL,AUTHENTICATED,AUTHID,' +
329     'AUTOALLOCATE,AUTOEXTEND,AUTOMATIC,BACKGROUND_CORE_DUMP,' +
330     'BACKGROUND_DUMP_DEST,BACKUP,BACKUP_TAPE_IO_SLAVES,BECOME,BEFORE,' +
331     'BEHALF,BETWEEN,BINDING,BITMAP,BITMAP_MERGE_AREA_SIZE,BLANK_TRIMMING,' +
332     'BLOCK,BLOCKSIZE,BUFFER_POOL,BUFFER_POOL_KEEP,BUFFER_POOL_RECYCLE,BY,' +
333     'CACHE,CANCEL,CASCADE,CAST,CATEGORY,CHAINED,CHANGE,CHARACTER,CHECK,' +
334     'CHECKPOINT,CHILD,CHUNK,CIRCUITS,CLASS,CLONE,CLUSTER,CLUSTER_DATABASE,' +
335     'CLUSTER_DATABASE_INSTANCES,CLUSTER_INTERCONNECTS,COALESCE,COBOL,' +
336     'COLUMN,COLUMNS,COMMENT,COMMIT_POINT_STRENGTH,COMPATIBLE,COMPILE,' +
337     'COMPLETE,COMPOSITE_LIMIT,COMPRESS,COMPUTE,CONNECT,' +
338     'CONNECT_TIME,CONSIDER,CONSTRAINT,CONSTRAINTS,CONTENTS,CONTEXT,CONTINUE,' +
339     'CONTROL,CONTROL_FILE_RECORD_KEEP_TIME,CONTROL_FILES,CONTROLFILE,' +
340     'CORE_DUMP_DEST,COST,CPU_COUNT,CPU_PER_CALL,CPU_PER_SESSION,CREATE,' +
341     'CREATE_BITMAP_AREA_SIZE,CREATE_STORED_OUTLINES,CURRENT,CURRENT_USER,' +
342     'CURSOR_SHARING,CURSOR_SPACE_FOR_TIME,CYCLE,DANGLING,DATAFILE,' +
343     'DB_BLOCK_BUFFERS,DB_BLOCK_CHECKING,DB_BLOCK_CHECKSUM,DB_BLOCK_SIZE,' +
344     'DB_CACHE_ADVICE,DB_CACHE_SIZE,DB_CREATE_FILE_DEST,DB_DOMAIN,' +
345     'DB_FILE_MULTIBLOCK_READ_COUNT,DB_FILE_NAME_CONVERT,DB_FILES,' +
346     'DB_KEEP_CACHE_SIZE,DB_NAME,DB_RECYCLE_CACHE_SIZE,DB_WRITER_PROCESSES,' +
347     'DBLINK_ENCRYPT_LOGIN,DBWR_IO_SLAVES,DEALLOCATE,DEBUG,DEFAULT,DEFERRED,' +
348     'DEFINER,DELETE,DEMAND,DETERMINES,DG_BROKER_START,DICTIONARY,DIMENSION,' +
349     'DIRECTORY,DISABLE,DISASSOCIATE,DISK_ASYNCH_IO,DISMOUNT,DISPATCHERS,' +
350     'DISTINCT,DISTRIBUTED,DISTRIBUTED_LOCK_TIMEOUT,DML,DML_LOCKS,DOCUMENT,' +
351     'DROP,DRS_START,ELSE,ENABLE,ENQUEUE_RESOURCES,ESCAPE,ESTIMATE,EVENT,' +
352     'EVENTS,EXCEPT,EXCEPTIONS,EXCHANGE,EXCLUDING,EXCLUSIVE,EXISTS,EXPIRE,' +
353     'EXPLAIN,EXTENT,EXTERNALLY,FAILED_LOGIN_ATTEMPTS,FAL_CLIENT,FAL_SERVER,' +
354     'FAST,FAST_START_IO_TARGET,FAST_START_MTTR_TARGET,' +
355     'FAST_START_PARALLEL_ROLLBACK,FILE,FILE_MAPPING,FILESYSTEMIO_OPTIONS,' +
356     'FIXED_DATE,FLUSH,FOR,FORCE,FOREIGN,FORTRAN,FREELIST,FREELISTS,FRESH,' +
357     'FROM,FROM_TZ,FUNCTIONS,GC_FILES_TO_LOCKS,GENERATED,GLOBAL,' +
358     'GLOBAL_CONTEXT_POOL_SIZE,GLOBAL_NAME,GLOBAL_NAMES,GLOBALLY,GO,GRANT,' +
359     'GROUP,GROUPS,HASH,HASH_AREA_SIZE,HASH_JOIN_ENABLED,HASHKEYS,HAVING,HEAP,' +
360     'HI_SHARED_MEMORY_ADDRESS,HIERARCHY,HS_AUTOREGISTER,IDENTIFIED,IDLE_TIME,' +
361     'IFILE,IMMEDIATE,IN,INCLUDING,INCREMENT,INDEX,INDEXTYPE,INDEXTYPES,' +
362     'INFILE,INITIAL,INITIALIZED,INITIALLY,INITRANS,INSERT,INSTANCE,' +
363     'INSTANCE_GROUPS,INSTANCE_NAME,INSTANCE_NUMBER,INT,INTERSECT,INTO,' +
364     'INVALIDATE,IS,ISOLATION,JAVA,JAVA_MAX_SESSIONSPACE_SIZE,JAVA_POOL_SIZE,' +
365     'JAVA_SOFT_SESSIONSPACE_LIMIT,JOB_QUEUE_PROCESSES,JOIN,KEEP,KEY,KILL,' +
366     'LARGE_POOL_SIZE,LAYERLISTS,LEVEL,LIBRARY,LICENSE_MAX_SESSIONS,' +
367     'LICENSE_MAX_USERS,LICENSE_SESSIONS_WARNING,LIKE,LIMIT,LINK,LIST,LOB,' +
368     'LOCAL,LOCAL_LISTENER,LOCATOR,LOCK,LOCK_NAME_SPACE,LOCK_SGA,' +
369     'LOG_ARCHIVE_DEST,LOG_ARCHIVE_DUPLEX_DEST,LOG_ARCHIVE_FORMAT,' +
370     'LOG_ARCHIVE_MAX_PROCESSES,LOG_ARCHIVE_MIN_SUCCEED_DEST,' +
371     'LOG_ARCHIVE_START,LOG_ARCHIVE_TRACE,LOG_BUFFER,LOG_CHECKPOINT_INTERVAL,' +
372     'LOG_CHECKPOINT_TIMEOUT,LOG_CHECKPOINTS_TO_ALERT,LOG_FILE_NAME_CONVERT,' +
373     'LOG_PARALLELISM,LOGFILE,LOGGING,LOGICAL_READS_PER_CALL,' +
374     'LOGICAL_READS_PER_SESSION,LOGMNR_MAX_PERSISTENT_SESSIONS,MANAGE,MANAGED,' +
375     'MANUAL,MAP,MASTER,MATCHED,MATERIALIZED,MAX_COMMIT_PROPAGATION_DELAY,' +
376     'MAX_DISPATCHERS,MAX_DUMP_FILE_SIZE,MAX_ENABLED_ROLES,' +
377     'MAX_ROLLBACK_SEGMENTS,MAX_SHARED_SERVERS,MAXDATAFILES,MAXEXTENTS,' +
378     'MAXINSTANCES,MAXLOGFILES,MAXLOGHISTORY,MAXLOGMEMBERS,MAXSIZE,MAXTRANS,' +
379     'MAXVALUE,MEMBER,MINEXTENTS,MINIMIZE,MINIMUM,MINUS,MINVALUE,MODE,MODIFY,' +
380     'MODULE,MONITORING,MOUNT,MOVE,MOVEMENT,MULTISET,NAMED,NATIONAL,NESTED,' +
381     'NEVER,NEXT,NLS_CALENDAR,NLS_COMP,NLS_CURRENCY,NLS_DATE_FORMAT,' +
382     'NLS_DATE_LANGUAGE,NLS_DUAL_CURRENCY,NLS_ISO_CURRENCY,NLS_LANGUAGE,' +
383     'NLS_LENGTH_SEMANTICS,NLS_NCHAR_CONV_EXCP,NLS_NUMERIC_CHARACTERS,' +
384     'NLS_TERRITORY,NLS_TIMESTAMP_FORMAT,NLS_TIMESTAMP_TZ_FORMAT,NO,' +
385     'NOARCHIVELOG,NOAUDIT,NOCACHE,NOCOMPRESS,NOCOPY,NOCYCLE,NOFORCE,' +
386     'NOLOGGING,NOMAXVALUE,NOMINIMIZE,NOMINVALUE,NOMONITORING,NONE,' +
387     'NOORDER,NORELY,NORESETLOGS,NOREVERSE,NORMAL,NOROWDEPENDENCIES,NOSORT,' +
388     'NOT,NOTHING,NOVALIDATE,NOWAIT,NULL,O7_DICTIONARY_ACCESSIBILITY,' +
389     'OBJECT_CACHE_MAX_SIZE_PERCENT,OBJECT_CACHE_OPTIMAL_SIZE,OF,OFFLINE,OID,' +
390     'OLAP_PAGE_POOL_SIZE,ON,ONLINE,ONLY,OPEN_CURSORS,OPEN_LINKS,' +
391     'OPEN_LINKS_PER_INSTANCE,OPERATOR,OPTIMAL,OPTIMIZER_DYNAMIC_SAMPLING,' +
392     'OPTIMIZER_FEATURES_ENABLE,OPTIMIZER_INDEX_CACHING,' +
393     'OPTIMIZER_INDEX_COST_ADJ,OPTIMIZER_MAX_PERMUTATIONS,OPTIMIZER_MODE,' +
394     'OPTION,OR,ORACLE_TRACE_COLLECTION_NAME,ORACLE_TRACE_COLLECTION_PATH,' +
395     'ORACLE_TRACE_COLLECTION_SIZE,ORACLE_TRACE_ENABLE,' +
396     'ORACLE_TRACE_FACILITY_NAME,ORACLE_TRACE_FACILITY_PATH,ORDER,' +
397     'OS_AUTHENT_PREFIX,OS_ROLES,OUTLINE,OVERFLOW,OWN,PACKAGES,PARALLEL,' +
398     'PARALLEL_ADAPTIVE_MULTI_USER,PARALLEL_AUTOMATIC_TUNING,' +
399     'PARALLEL_EXECUTION_MESSAGE_SIZE,PARALLEL_INSTANCE_GROUP,' +
400     'PARALLEL_MAX_SERVERS,PARALLEL_MIN_PERCENT,PARALLEL_MIN_SERVERS,' +
401     'PARALLEL_THREADS_PER_CPU,PARAMETERS,PARTITION_VIEW_ENABLED,PARTITIONS,' +
402     'PASSWORD,PASSWORD_GRACE_TIME,PASSWORD_LIFE_TIME,PASSWORD_LOCK_TIME,' +
403     'PASSWORD_REUSE_MAX,PASSWORD_REUSE_TIME,PASSWORD_VERIFY_FUNCTION,' +
404     'PCTFREE,PCTINCREASE,PCTTHRESHOLD,PCTUSED,PCTVERSION,PERCENT,PERMANENT,' +
405     'PGA_AGGREGATE_TARGET,PIPELINED,PLAN,PLI,PLSQL_COMPILER_FLAGS,' +
406     'PLSQL_NATIVE_C_COMPILER,PLSQL_NATIVE_LIBRARY_DIR,' +
407     'PLSQL_NATIVE_LIBRARY_SUBDIR_COUNT,PLSQL_NATIVE_LINKER,' +
408     'PLSQL_NATIVE_MAKE_FILE_NAME,PLSQL_NATIVE_MAKE_UTILITY,' +
409     'PLSQL_V2_COMPATIBILITY,POST_TRANSACTION,PRE_PAGE_SGA,PREBUILD,PRECISION,' +
410     'PRIMARY,PRIOR,PRIVATE_SGA,PRIVILEGES,PROCESSES,PROFILE,PUBLIC,QUERY,' +
411     'QUERY_REWRITE_ENABLED,QUERY_REWRITE_INTEGRITY,QUIESCE,QUOTA,' +
412     'RDBMS_SERVER_DN,READ,READ_ONLY_OPEN_DELAYED,REBUILD,RECORDS_PER_BLOCK,' +
413     'RECOVER,RECOVERABLE,RECOVERY,RECOVERY_PARALLELISM,RECYCLE,REDUCED,' +
414     'REFERENCES,REFRESH,REGISTER,RELY,REMOTE_ARCHIVE_ENABLE,' +
415     'REMOTE_DEPENDENCIES_MODE,REMOTE_LISTENER,REMOTE_LOGIN_PASSWORDFILE,' +
416     'REMOTE_OS_AUTHENT,REMOTE_OS_ROLES,RENAME,' +
417     'REPLICATION_DEPENDENCY_TRACKING,RESET,RESETLOGS,RESIZE,RESOLVE,RESOLVER,' +
418     'RESOURCE,RESOURCE_LIMIT,RESOURCE_MANAGER_PLAN,RESTRICT,RESTRICTED,' +
419     'RESUMABLE,RESUME,REUSE,REVOKE,REWRITE,RNDS,RNPS,ROLE,ROLES,' +
420     'ROLLBACK_SEGMENTS,ROW,ROW_LOCKING,ROWDEPENDENCIES,ROWLABEL,ROWNUM,' +
421     'ROWS,SAMPLE,SCN,SCOPE,SECTION,SEGMENT,SELECT,SELECTIVITY,SEQUENCE,' +
422     'SERIAL_REUSE,SERVICE_NAMES,SESSION,SESSION_CACHED_CURSORS,' +
423     'SESSION_MAX_OPEN_FILES,SESSIONS,SESSIONS_PER_USER,SGA_MAX_SIZE,' +
424     'SHADOW_CORE_DUMP,SHARE,SHARED,SHARED_MEMORY_ADDRESS,SHARED_POOL,' +
425     'SHARED_POOL_RESERVED_SIZE,SHARED_POOL_SIZE,SHARED_SERVER_SESSIONS,' +
426     'SHARED_SERVERS,SHRINK,SIZE,SNAPSHOT,SOME,SORT,SORT_AREA_RETAINED_SIZE,' +
427     'SORT_AREA_SIZE,SOURCE,SPECIFICATION,SPECIFIED,SPFILE,SPLIT,SQL_TRACE,' +
428     'SQL92_SECURITY,STANDBY,STANDBY_ARCHIVE_DEST,STANDBY_FILE_MANAGEMENT,' +
429     'STAR_TRANSFORMATION_ENABLED,START,START_DATE,STATISTICS,' +
430     'STATISTICS_LEVEL,STOP,STORAGE,STRUCTURE,SUBPARTITION,SUBPARTITIONS,' +
431     'SUCCESSFUL,SUSPEND,SWITCH,SYNONYM,SYSTEM,TABLE,TABLESPACE,' +
432     'TAPE_ASYNCH_IO,TEMPFILE,TEMPORARY,THE,THEN,THREAD,THROUGH,TIME,' +
433     'TIMED_OS_STATISTICS,TIMED_STATISTICS,TIMEOUT,TO,TRACE_ENABLED,' +
434     'TRACEFILE_IDENTIFIER,TRACING,TRANSACTION,TRANSACTION_AUDITING,' +
435     'TRANSACTIONS,TRANSACTIONS_PER_ROLLBACK_SEGMENT,TRIGGER,TRUNCATE,TRUST,' +
436     'TYPES,UNARCHIVED,UNDER,UNDO,UNDO_MANAGEMENT,UNDO_RETENTION,' +
437     'UNDO_SUPPRESS_ERRORS,UNDO_TABLESPACE,UNIFORM,UNION,UNIQUE,UNLIMITED,' +
438     'UNLOCK,UNQUIESCE,UNRECOVERABLE,UNTIL,UNUSABLE,UNUSED,UPDATE,USAGE,' +
439     'USE_INDIRECT_DATA_BUFFERS,USER_DUMP_DEST,VALIDATE,VALIDATION,VALUES,' +
440     'VARGRAPHIC,VARRAY,VIEW,WHERE,WITH,WITHOUT,WNDS,WNPS,' +
441     'WORKAREA_SIZE_POLICY';
442 
443   // PLSQL keywords
444   OraclePLSQLKW: string =
445     'ABORT,ACCEPT,AFTER,ARRAY,ARRAYLEN,ASSERT,ASSIGN,AT,AUTHORIZATION,' +
446     'AUTONOMOUS_TRANSACTION,BASE_TABLE,BEGIN,BODY,BULK,BULK_ROWCOUNT,CALL,' +
447     'CALLING,CASE,CHAR_BASE,CHARSETFORM,CHARSETID,CLOSE,CLUSTERS,COLAUTH,' +
448     'COLLECT,COMMIT,CONNECTION,CONSTANT,COOKIE,COOKIE_TABLE,CRASH,CURRVAL,' +
449     'CURSOR,DATA_BASE,DATABASE,DBA,DEBUGOFF,DEBUGON,DECLARE,DEFINITION,' +
450     'DELAY,DELTA,DEQUEUE_OPTIONS_T,DETERMINISTIC,DIGITS,DISPOSE,DO,EACH,' +
451     'ELSIF,END,ENQUEUE_OPTIONS_T,ENTRY,EXCEPTION,EXCEPTION_INIT,EXIT,' +
452     'EXTERNAL,FALSE,FETCH,FIXED,FORALL,FORM,FOUND,FUNCTION,GENERIC,GOTO,IF,' +
453     'INDEXES,INDICATOR,INSTEAD,INTERFACE,ISOPEN,LANGUAGE,LCR$_DDL_RECORD,' +
454     'LCR$_ROW_LIST,LCR$_ROW_RECORD,LCR$_ROW_UNIT,LIMITED,LOOP,MAXLEN,' +
455     'MESSAGE_PROPERTIES_T,MGW_BASIC_MSG_T,MGW_MQSERIES_PROPERTIES,' +
456     'MGW_NAME_TYPE_ARRAY_T,MGW_NAME_VALUE_T,MGW_PROPERTIES,MGW_PROPERTY,' +
457     'MGW_RAW_VALUE_T,MGW_TEXT_VALUE_T,NAME,NEW,NEXTVAL,NOTFOUND,' +
458     'NUMBER_BASE,OLD,OPEN,OUT,PACKAGE,PARALLEL_ENABLE,PARTITION,PASCAL,' +
459     'PRAGMA,PRIVATE,PROCEDURE,RAISE,RANGE,RE$ATTRIBUTE_VALUE,' +
460     'RE$ATTRIBUTE_VALUE_LIST,RE$COLUMN_VALUE,RE$COLUMN_VALUE_LIST,' +
461     'RE$NAME_ARRAY,RE$NV_ARRAY,RE$NV_LIST,RE$NV_NODE,RE$RULE_HIT,' +
462     'RE$RULE_HIT_LIST,RE$TABLE_ALIAS,RE$TABLE_ALIAS_LIST,' +
463     'RE$TABLE_VALUE,RE$TABLE_VALUE_LIST,RE$VARIABLE_TYPE,' +
464     'RE$VARIABLE_TYPE_LIST,RE$VARIABLE_VALUE,RE$VARIABLE_VALUE_LIST,RECORD,' +
465     'REF,REFERENCING,RELEASE,REMR,REQ,RESP,RESTRICT_REFERENCES,RETURN,' +
466     'REVERSE,ROLLBACK,ROWCOUNT,ROWTYPE,RUNTIME_INFO,SAVEPOINT,SCHEMA,' +
467     'SELF,SEPARATE,SERIALLY_REUSABLE,SPACE,SQL,SQLERROR,STATEMENT,STRUCT,' +
468     'SUBTYPE,TABAUTH,TABLES,TASK,TDO,TERMINATE,TRUE,TYPE,USE,VARYING,VIEWS,' +
469     'WHEN,WHILE,WORK,WRITE,XOR';
470 
471   // Oracle data types
472   OracleTypes: string =
473     'ANYDATA,ANYDATASET,ANYTYPE,BFILE,BINARY_INTEGER,BLOB,BOOLEAN,CHAR,CLOB,' +
474     'DATE,DAY,DBURIType,DEC,DECIMAL,DOUBLE,FLOAT,HTTPURIType,INTEGER,LONG,' +
475     'MLSLABEL,MONTH,NATURAL,NATURALN,NCHAR,NCLOB,NUMBER,NUMERIC,' +
476     'NVARCHAR2,PLS_INTEGER,POSITIVE,POSITIVEN,RAW,REAL,ROWID,SECOND,SMALLINT,' +
477     'TIMESTAMP,URIType,UROWID,VARCHAR,VARCHAR2,XDBURIType,XMLDATA,XMLType,' +
478     'YEAR,ZONE';
479 
480   // Oracle built in exceptions
481   OracleExceptions: string =
482     'ACCESS_INTO_NULL,COLLECTION_IS_NULL,CURSOR_ALREADY_OPEN,' +
483     'DUP_VAL_ON_INDEX,INVALID_CURSOR,INVALID_NUMBER,LOGIN_DENIED,' +
484     'NO_DATA_FOUND,NOT_LOGGED_ON,OTHERS,PROGRAM_ERROR,ROWTYPE_MISMATCH,' +
485     'STORAGE_ERROR,SUBSCRIPT_BEYOND_COUNT,SUBSCRIPT_OUTSIDE_LIMIT,' +
486     'SYS_INVALID_ROWID,TIMEOUT_ON_RESOURCE,TOO_MANY_ROWS,VALUE_ERROR,' +
487     'ZERO_DIVIDE';
488 
489   // Oracle built in functions
490   OracleFunctions: string =
491     'ABS,ACOS,ADD_MONTHS,AGGREGATE,ANALYTIC,ASCII,ASCIISTR,ASIN,ATAN,ATAN2,' +
492     'AVERAGE,AVG,BASE64_DECODE,BASE64_ENCODE,BEGIN_REQUEST,BFILENAME,' +
493     'BIN_TO_NUM,BIT_AND,BIT_COMPLEMENT,BIT_OR,BIT_XOR,BITAND,' +
494     'CAST_FROM_BINARY_INTEGER,CAST_FROM_NUMBER,CAST_TO_BINARY_INTEGER,' +
495     'CAST_TO_NUMBER,CAST_TO_RAW,CAST_TO_VARCHAR2,CEIL,CHARTOROWID,CHR,' +
496     'COLUMN_PRESENT,COMPARE,COMPARE_TEMPLATES,COMPOSE,CONCAT,CONVERSION,' +
497     'CONVERT,CONVERT_ANYDATA_TO_LCR_DDL,CONVERT_ANYDATA_TO_LCR_ROW,' +
498     'COPIES,COPY_TEMPLATE,CORR,COS,COSH,COUNT,COVAR_POP,COVAR_SAMP,' +
499     'CREATE_OBJECT_FROM_EXISTING,CREATE_PIPE,CREATE_REFRESH_TEMPLATE,' +
500     'CREATE_TEMPLATE_OBJECT,CREATE_TEMPLATE_PARM,CREATE_USER_AUTHORIZATION,' +
501     'CREATE_USER_PARM_VALUE,CRLF,CUBE,CUME_DIST,CURRENT_DATE,' +
502     'CURRENT_INSTANCE,CURRENT_TIMESTAMP,DATA_BLOCK_ADDRESS_BLOCK,' +
503     'DATA_BLOCK_ADDRESS_FILE,DBTIMEZONE,DECODE,DECOMPOSE,DELETE_BREAKPOINT,' +
504     'DELETE_OER_BREAKPOINT,DENSE_RANK,DEPTH,DEREF,DISABLE_BREAKPOINT,' +
505     'DISABLED,DISPLAY,DROP_ALL,DROP_ELEMENT,DROP_FILE,DUMP,' +
506     'EMPTY_BLOB,EMPTY_CLOB,ENABLE_BREAKPOINT,EQUALS_PATH,ESTIMATE_CPU_UNITS,' +
507     'EXCLUDE_PUSH,EXECUTE_AND_FETCH,EXECUTE_NON_QUERY,EXISTSNODE,EXP,EXTEND,' +
508     'EXTRACT,EXTRACTVALUE,FCOPY,FETCH_ROW,FETCH_ROWS,FGETPOS,FILEEXISTS,' +
509     'FILEISOPEN,FIRST,FIRST_VALUE,FLOOR,FLUSH_DATA,FOPEN,FOPEN_NCHAR,' +
510     'FORMAT_CALL_STACK,FORMAT_ERROR_STACK,FREMOVE,FRENAME,FROM_REMOTE,FSEEK,' +
511     'GET_ARG_FORM,GET_ARG_TYPE,GET_COOKIE_COUNT,GET_COOKIES,' +
512     'GET_DETAILED_SQLCODE,GET_DETAILED_SQLERRM,GET_ERROR_MESSAGE,' +
513     'GET_HASH_VALUE,GET_HEADER_COUNT,GET_INDEXES,GET_INFORMATION,' +
514     'GET_OBJECT_NULL_VECTOR_ARG,GET_PARAMETER_VALUE,' +
515     'GET_PERSISTENT_CONN_COUNT,GET_RAW,GET_RESPONSE,GET_RUNTIME_INFO,' +
516     'GET_RUNTIME_PARM_ID,GET_SESSION_TIMEOUT,GET_SYSTEM_CHANGE_NUMBER,' +
517     'GET_TAG,GET_TIME,GET_TIMEOUT,GET_TIMEOUT_BEHAVIOR,GET_VALUE,' +
518     'GETCHUNKSIZE,GETLENGTH,GLB,GREATEST,GREATEST_LB,GROUP_ID,GROUPING,' +
519     'GROUPING_ID,HEXTORAW,I_AM_A_REFRESH,INITCAP,INITIALIZE,' +
520     'INSTANTIATE_OFFLINE,INSTANTIATE_ONLINE,INSTR,INSTRB,' +
521     'INTERNAL_VERSION_CHECK,IS_CLUSTER_DATABASE,IS_LOCATOR,IS_OPEN,' +
522     'IS_ROLE_ENABLED,IS_SESSION_ALIVE,IS_TRIGGER_FIRE_ONCE,ISTEMPORARY,LAG,' +
523     'LAST,LAST_DAY,LAST_ERROR_POSITION,LAST_ROW_COUNT,LAST_ROW_ID,' +
524     'LAST_SQL__CODE,LAST_VALUE,LEAD,LEAST,LEAST_LB,LENGTH,LENGTHB,LINEAR,LN,' +
525     'LOCAL_TRANSACTION_ID,LOCALTIMESTAMP,LOG,LOWER,LPAD,LTRIM,LUB,' +
526     'MAKE_DATA_BLOCK_ADDRESS,MAKE_REF,MAP_ALL,MAP_ELEMENT,MAP_FILE,' +
527     'MAP_OBJECT,MAX,MIN,MINE_VALUE,MISCELLANEOUS,MOD,MONTHS_BETWEEN,NCHR,' +
528     'NEW_TIME,NEXT_DAY,NEXT_ITEM_TYPE,NLS_CHARSET_DECL_LEN,NLS_CHARSET_ID,' +
529     'NLS_CHARSET_NAME,NLS_INITCAP,NLS_LOWER,NLS_SORT,NLS_UPPER,NLSSORT,NTILE,' +
530     'NULLIF,NUMTODSINTERVAL,NUMTOYMINTERVAL,NVARRAY_FIND_NAME,' +
531     'NVARRAY_FIND_NAME_TYPE,NVARRAY_GET,NVARRAY_GET_BOOLEAN,NVARRAY_GET_BYTE,' +
532     'NVARRAY_GET_DATE,NVARRAY_GET_DOUBLE,NVARRAY_GET_FLOAT,' +
533     'NVARRAY_GET_INTEGER,NVARRAY_GET_LONG,NVARRAY_GET_RAW,NVARRAY_GET_SHORT,' +
534     'NVARRAY_GET_TEXT,NVL,NVL2,OBJECT,OPEN_CURSOR,OVER,OVERLAY,PATH,' +
535     'PAUSE_PROFILER,PERCENT_RANK,PERCENTILE_CONT,PERCENTILE_DISC,PMARKER,' +
536     'PORT_STRING,POWER,PURGE,PUSH,PUT_RAW,QUOTED_PRINTABLE_DECODE,' +
537     'QUOTED_PRINTABLE_ENCODE,RANDOM,RANK,RATIO_TO_REPORT,RATION_TO_REPORT,' +
538     'RAWTOHEX,RAWTONHEX,RECEIVE_MESSAGE,REFERENCE,REFTOHEX,REGR_AVGX,' +
539     'REGR_AVGY,REGR_COUNT,REGR_INTERCEPT,REGR_R2,REGR_SLOPE,REGR_SXX,' +
540     'REGR_SXY,REGR_SYY,REGRESSION,REMOVE_PIPE,REPLACE,REPLICATION_IS_ON,' +
541     'REQUEST,REQUEST_PIECES,RESTORE,RESUME_PROFILER,RETURNING,ROLLUP,ROUND,' +
542     'ROW_NUMBER,ROWID_BLOCK_NUMBER,ROWID_CREATE,ROWID_OBJECT,' +
543     'ROWID_RELATIVE_FNO,ROWID_ROW_NUMBER,ROWID_TO_ABSOLUTE_FNO,' +
544     'ROWID_TO_EXTENDED,ROWID_TO_RESTRICTED,ROWID_TYPE,ROWID_VERIFY,' +
545     'ROWIDTOCHAR,ROWIDTONCHAR,RPAD,RTRIM,SEND_MESSAGE,SESSIONTIMEZONE,' +
546     'SET_BREAKPOINT,SET_OER_BREAKPOINT,SET_TIMEOUT,SET_VALUE,SIGN,SIN,SINH,' +
547     'SOUNDEX,SPACE_ERROR_INFO,SQLCODE,SQLERRM,SQRT,START_PROFILER,STDDEV,' +
548     'STDDEV_POP,STDDEV_SAMP,STDDEVP,STDDEVS,STEP_ID,STOP_PROFILER,SUBSTR,' +
549     'SUBSTRB,SUM,SYNCHRONIZE,SYS_CONNECT_BY_PATH,SYS_CONTEXT,SYS_DBURIGEN,' +
550     'SYS_EXTRACT_UTC,SYS_GUID,SYS_TYPEID,SYS_XMLAGG,SYS_XMLGEN,SYSDATE,' +
551     'SYSTIMESTAMP,TAN,TANH,TO_CHAR,TO_CLOB,TO_DATE,TO_DSINTERVAL,TO_LABEL,' +
552     'TO_LOB,TO_MULTI_BYTE,TO_NCHAR,TO_NCLOB,TO_NUMBER,TO_SINGLE_BYTE,' +
553     'TO_TIMESTAMP,TO_TIMESTAMP_TZ,TO_YMINTERVAL,TRANSLATE,TRANSLITERATE,' +
554     'TREAT,TRIM,TRUNC,TZ_OFFSET,UID,UNDER_PATH,UNESCAPE,UNIQUE_SESSION_ID,' +
555     'UNIQUE_SESSION_NAME,UNISTR,UPDATEXML,UPPER,USER,USERENV,USING,UUDECODE,' +
556     'UUENCODE,VALUE,VAR_POP,VAR_SAMP,VARIANCE,VARP,VARS,VSIZE,WIDTH_BUCKET,' +
557     'XMLAGG,XMLCOLATTVAL,XMLCONCAT,XMLELEMENT,XMLFOREST,XMLSEQUENCE,' +
558     'XMLTRANSFORM,XRANGE';
559 
560   OracleDefaultPackages: string =
561     'DBMS_ALERT,DBMS_APPLICATION_INFO,DBMS_APPLY_ADM,DBMS_AQ,' +
562     'DBMS_AQ_EXP_HISTORY_TABLES,DBMS_AQ_EXP_INDEX_TABLES,' +
563     'DBMS_AQ_EXP_QUEUE_TABLES,DBMS_AQ_EXP_QUEUES,' +
564     'DBMS_AQ_EXP_SUBSCRIBER_TABLES,DBMS_AQ_EXP_TIMEMGR_TABLES,' +
565     'DBMS_AQ_EXP_ZECURITY,DBMS_AQ_IMP_INTERNAL,DBMS_AQ_IMP_ZECURITY,' +
566     'DBMS_AQ_IMPORT_INTERNAL,DBMS_AQ_SYS_EXP_ACTIONS,' +
567     'DBMS_AQ_SYS_EXP_INTERNAL,DBMS_AQ_SYS_IMP_INTERNAL,DBMS_AQADM,' +
568     'DBMS_AQADM_SYS,DBMS_AQADM_SYSCALLS,DBMS_AQELM,DBMS_AQIN,' +
569     'DBMS_AQJMS,DBMS_BACKUP_RESTORE,DBMS_CAPTURE_ADM,DBMS_DDL,' +
570     'DBMS_DEBUG,DBMS_DEFER,DBMS_DEFER_IMPORT_INTERNAL,DBMS_DEFER_QUERY,' +
571     'DBMS_DEFER_SYS,DBMS_DESCRIBE,DBMS_DISTRIBUTED_TRUST_ADMIN,' +
572     'DBMS_EXPORT_EXTENSION,DBMS_FGA,DBMS_FLASHBACK,DBMS_HS_PASSTHROUGH,' +
573     'DBMS_IJOB,DBMS_INTERNAL_TRIGGER,DBMS_IOT,DBMS_IREFRESH,DBMS_ISNAPSHOT,' +
574     'DBMS_JAVA_TEST,DBMS_JOB,DBMS_LDAP,DBMS_LIBCACHE,DBMS_LOB,DBMS_LOCK,' +
575     'DBMS_LOGMNR,DBMS_LOGMNR_CDC_PUBLISH,DBMS_LOGMNR_CDC_SUBSCRIBE,' +
576     'DBMS_LOGMNR_D,DBMS_LOGSTDBY,DBMS_METADATA,DBMS_MGWADM,' +
577     'DBMS_MGWMSG,DBMS_MVIEW,DBMS_OBFUSCATION_TOOLKIT,DBMS_ODCI,' +
578     'DBMS_OFFLINE_OG,DBMS_OFFLINE_SNAPSHOT,DBMS_OLAP,' +
579     'DBMS_ORACLE_TRACE_AGENT,DBMS_ORACLE_TRACE_USER,DBMS_OUTLN,' +
580     'DBMS_OUTLN_EDIT,DBMS_OUTPUT,DBMS_PCLXUTIL,DBMS_PICKLER,DBMS_PIPE,' +
581     'DBMS_PITR,DBMS_PLUGTS,DBMS_PROFILER,DBMS_PROPAGATION_ADM,' +
582     'DBMS_PRVTAQIM,DBMS_PRVTAQIP,DBMS_PRVTAQIS,DBMS_PRVTRMIE,DBMS_PSP,' +
583     'DBMS_PSWMG_IMPORT,DBMS_RANDOM,DBMS_RCVMAN,DBMS_RECTIFIER_DIFF,' +
584     'DBMS_REDEFINITION,DBMS_REFRESH,DBMS_REFRESH_EXP_LWM,' +
585     'DBMS_REFRESH_EXP_SITES,DBMS_REPAIR,DBMS_REPCAT,DBMS_REPCAT_ADMIN,' +
586     'DBMS_REPCAT_AUTH,DBMS_REPCAT_INSTANTIATE,DBMS_REPCAT_RGT,DBMS_REPUTIL,' +
587     'DBMS_RESOURCE_MANAGER,DBMS_RESOURCE_MANAGER_PRIVS,DBMS_RESUMABLE,' +
588     'DBMS_RLS,DBMS_RMGR_GROUP_EXPORT,DBMS_RMGR_PACT_EXPORT,' +
589     'DBMS_RMGR_PLAN_EXPORT,DBMS_RMIN,DBMS_ROWID,DBMS_RULE,DBMS_RULE_ADM,' +
590     'DBMS_RULE_EXIMP,DBMS_SESSION,DBMS_SHARED_POOL,DBMS_SNAP_INTERNAL,' +
591     'DBMS_SNAP_REPAPI,DBMS_SNAPSHOT,DBMS_SNAPSHOT_UTL,DBMS_SPACE,' +
592     'DBMS_SPACE_ADMIN,DBMS_SQL,DBMS_STANDARD,DBMS_STATS,DBMS_STORAGE_MAP,' +
593     'DBMS_STREAMS,DBMS_STREAMS_ADM,DBMS_SUMADV,DBMS_SUMMARY,' +
594     'DBMS_SUMREF_CHILD,DBMS_SUMREF_PARENT,DBMS_SUMREF_UTIL,' +
595     'DBMS_SUMREF_UTIL2,DBMS_SUMVDM,DBMS_SYS_ERROR,DBMS_SYS_SQL,' +
596     'DBMS_SYSTEM,DBMS_TRACE,DBMS_TRANSACTION,DBMS_TRANSFORM,DBMS_TTS,' +
597     'DBMS_TYPES,DBMS_UTILITY,DBMS_WM,DBMS_XDB,DBMS_XDB_VERSION,DBMS_XDBT,' +
598     'DBMS_XMLDOM,DBMS_XMLGEN,DBMS_XMLPARSER,DBMS_XMLQUERY,' +
599     'DBMS_XMLSAVE,DBMS_XPLAN,DBMS_XSLPROCESSOR,DBMS_ZHELP,DBMS_ZHELP_IR,' +
600     'DBMSZEXP_SYSPKGGRNT,DEBUG_EXTPROC,DIANA,DIUTIL,ODCICONST,OUTLN_PKG,' +
601     'PBREAK,PBRPH,PBSDE,PBUTL,PIDL,PLITBLM,SDO_CS,SDO_GEOM,SDO_LRS,' +
602     'SDO_MIGRATE,SDO_TUNE,SDO_UTIL,STANDARD,SYS_STUB_FOR_PURITY_ANALYSIS,' +
603     'UTL_COLL,UTL_ENCODE,UTL_FILE,UTL_FILE_DIR,UTL_HTTP,UTL_INADDR,UTL_PG,' +
604     'UTL_RAW,UTL_REF,UTL_SMTP,UTL_TCP,UTL_URL';
605 
606   OracleSQLPlusCommands: string =
607     'APP,APPINFO,AQ$_AGENT,AQ$_AGENT_LIST_T,AQ$_DESCRIPTOR,AQ$_POST_INFO,' +
608     'AQ$_POST_INFO_LIST,AQ$_RECIPIENT_LIST_T,AQ$_REG_INFO,AQ$_REG_INFO_LIST,' +
609     'AQ$_SUBSCRIBER_LIST_T,ARCHIVE,ARRAYSIZE,ATTRIBUTE,AUTOCOMMIT,AUTOP,' +
610     'AUTOPRINT,AUTORECOVERY,AUTOT,AUTOTRACE,BLO,BLOCKTERMINATOR,BRE,BREAK,' +
611     'BTI,BTITLE,BUFFER,CL,CLEAR,CLOSECURSOR,CMDS,CMDSEP,COL,COLSEP,COM,COMP,' +
612     'COMPAT,COMPATIBILITY,CON,CONN,COPY,COPYC,COPYCOMMIT,COPYTYPECHECK,DEF,' +
613     'DEFINE,DESC,DESCR,DESCRI,DESCRIB,DESCRIBE,DISC,DISCO,DISCON,DISCONN,' +
614     'DISCONNE,DISCONNEC,DISCONNECT,EA,ECHO,EDITF,EDITFILE,EMB,' +
615     'EMBEDDED,ESC,EXEC,EXECUTE,FAILURE,FEED,FEEDBACK,FLAGGER,FLU,FULL,GET,' +
616     'HEA,HEADING,HEADS,HEADSEP,HELP,HO,HOST,INPUT,INTERMED,INTERMEDIATE,INV,' +
617     'INVISIBLE,LIN,LINESIZE,LO,LOBOF,LOBOFFSET,LOGON,LOGSOURCE,LONGC,' +
618     'LONGCHUNKSIZE,MARKUP,MAXDATA,MIX,MIXED,NATIVE,NEWP,NEWPAGE,NUM,' +
619     'NUMF,NUMFORMAT,NUMWIDTH,OFF,OSERROR,PAGES,PAGESIZE,PASSW,PAU,PAUSE,' +
620     'PPRINT,PRI,PRINT,PROMPT,RECSEP,RECSEPCHAR,REPF,REPFOOTER,REPH,REPHEADER,' +
621     'RUN,SAVE,SCAN,SERVEROUTPUT,SET,SHIFT,SHIFTINOUT,SHO,SHOW,SHUTDOWN,' +
622     'SILENT,SPOOL,SQLBL,SQLBLANKLINES,SQLC,SQLCASE,SQLCO,SQLCONTINUE,SQLN,' +
623     'SQLNUMBER,SQLP,SQLPRE,SQLPREFIX,SQLPROMPT,SQLT,SQLTERMINATOR,STA,' +
624     'STARTUP,STATEMENT_ID,STORE,SUCCESS,SUF,SUFFIX,TAB,TERM,TERMOUT,TI,TIMI,' +
625     'TIMING,TRIMOUT,TRIMS,TRIMSPOOL,TTI,TTITLE,UND,UNDEF,UNDEFINE,' +
626     'UNDERLINE,UP,VAR,VARIABLE,VER,VERIFY,VERSION,VIS,VISIBLE,WHENEVER,WR,' +
627     'WRA,WRAP,WRAPPED';
628 
629   OracleCommentKW: string =
630     'REM,REMA,REMAR,REMARK';
631 
632   //---Postgresql-----------------------------------------------------------------
633   //Postgresql Keywords
634   PostgresKW: String =
635     'IF,LOOP,ABORT,ABSOLUTE,ACCESS,ACTION,ADA,ADD,ADMIN,AFTER,AGGREGATE,ALIAS' +
636     ',ALLOCATE,ALTER,ANALYSE,ANALYZE,AND,ARE,AS,ASC,ASENSITIVE' +
637     ',ASSERTION,ASSIGNMENT,ASYMMETRIC,AT,ATOMIC,AUTHORIZATION,BACKWARD' +
638     ',BEFORE,BEGIN,BETWEEN' +
639     ',BOTH,BREADTH,BY,C,CACHE,CALL,CALLED,CARDINALITY,CASCADE,CASCADED,CASE' +
640     ',CAST,CATALOG,CATALOG_NAME,CHAIN,CHARACTERISTICS' +
641     ',CHARACTER_SET_CATALOG,CHARACTER_SET_NAME,CHARACTER_SET_SCHEMA' +
642     ',CHECK,CHECKED,CHECKPOINT,CLASS,CLASS_ORIGIN,CLOB,CLOSE,CLUSTER,COBOL,COLLATE' +
643     ',COLLATION,COLLATION_CATALOG,COLLATION_NAME,COLLATION_SCHEMA,COLUMN,COLUMN_NAME' +
644     ',COMMAND_Function,COMMAND_Function_CODE,COMMENT,COMMIT,COMMITTED,COMPLETION' +
645     ',CONDITION_NUMBER,CONNECT,CONNECTION,CONNECTION_NAME,CONSTRAINT,CONSTRAINTS' +
646     ',CONSTRAINT_CATALOG,CONSTRAINT_NAME,CONSTRAINT_SCHEMA,CONSTRUCTOR,CONTAINS' +
647     ',CONTINUE,CONVERSION,COPY,CORRESPONDING,CREATE,CREATEDB,CREATEUSER' +
648     ',CROSS,CUBE,CURRENT,CURRENT_PATH,CURRENT_ROLE' +
649     ',CURSOR,CURSOR_NAME,CYCLE,DATA,DATABASE,DATETIME_INTERVAL_CODE' +
650     ',DATETIME_INTERVAL_PRECISION,DAY,DEALLOCATE,DEC,DECLARE,DEFAULT,DEFERRABLE' +
651     ',DEFERRED,DEFINED,DEFINER,DELETE,DELIMITER,DELIMITERS,DEPTH,DEREF,DESC,DESCRIBE' +
652     ',DESCRIPTOR,DESTROY,DESTRUCTOR,DETERMINISTIC,DIAGNOSTICS,DICTIONARY,DISCONNECT' +
653     ',DISPATCH,DISTINCT,DO,DOMAIN,DROP,DYNAMIC,DYNAMIC_Function,DYNAMIC_Function_CODE' +
654     ',EACH,ELSE,ELSIF,ELSEIF,ENCODING,ENCRYPTED,END,EQUALS,ESCAPE,EXCEPT,EXCEPTION' +
655     ',EXCLUSIVE,EXEC,EXECUTE,EXISTING,EXPLAIN,EXTERNAL,FALSE,FETCH' +
656     ',FINAL,FIRST,FOR,FORCE,FOREIGN,FORTRAN,FORWARD,FOUND,FREE,FREEZE,FROM' +
657     ',FULL,Function,G,GENERAL,GENERATED,GET,GLOBAL,GO,GOTO,GRANT,GRANTED,GROUP' +
658     ',GROUPING,HANDLER,HAVING,HIERARCHY,HOLD,HOUR,IDENTITY,IGNORE,ILIKE' +
659     ',IMMEDIATE,IMMUTABLE,IMPLEMENTATION,IMPLICIT,INCREMENT,INDEX,INDICATOR' +
660     ',INFIX,INHERITS,INITIALIZE,INITIALLY,INNER,INOUT,INPUT,INSENSITIVE,INSERT' +
661     ',INSTANCE,INSTANTIABLE,INSTEAD,INT,INTERSECT,INTO,INVOKER' +
662     ',IS,ISNULL,ISOLATION,ITERATE,JOIN,K,KEY,KEY_MEMBER,KEY_TYPE,LANCOMPILER,LANGUAGE' +
663     ',LARGE,LAST,LATERAL,LEADING,LEFT,LESS,LEVEL,LIKE,LIMIT,LISTEN,LOAD,LOCAL' +
664     ' LOCATION,LOCATOR,LOCK,M,MAP,MATCH,MAXVALUE,MESSAGE_LENGTH' +
665     ',MESSAGE_OCTET_LENGTH,MESSAGE_TEXT,METHOD,MINUTE,MINVALUE,MODE,MODIFIES' +
666     ',MODIFY,MODULE,MONTH,MORE,MOVE,MUMPS,NAME,NAMES,NATIONAL,NATURAL,NCHAR,NCLOB' +
667     ',NEW,NEXT,NO,NOCREATEDB,NOCREATEUSER,NONE,NOT,NOTHING,NOTIFY,NOTNULL,NULL,NULLABLE' +
668     ',NUMBER,OBJECT,OF,OFF,OFFSET,OIDS,OLD,ON,ONLY,OPEN' +
669     ',OPERATION,Operator,OPTION,OPTIONS,OR,ORDER,ORDINALITY,OUT,OUTER,OUTPUT,OVERLAPS' +
670     ',OVERRIDING,OWNER,PAD,PARAMETER,PARAMETERS,PARAMETER_MODE,PARAMETER_NAME,PARAMETER_ORDINAL_POSITION' +
671     ',PARAMETER_SPECIFIC_CATALOG,PARAMETER_SPECIFIC_NAME,PARAMETER_SPECIFIC_SCHEMA,PARTIAL,PASCAL,PASSWORD' +
672     ',PENDANT,PLACING,PLI,POSTFIX,PRECISION,PREFIX,PREORDER,PREPARE,PRESERVE,PRIMARY' +
673     ',PRIOR,PRIVILEGES,PROCEDURAL,PROCEDURE,PUBLIC,READ,READS,RECHECK,RECURSIVE,REF,REFERENCES' +
674     ',REFERENCING,REINDEX,RELATIVE,RENAME ,REPEATABLE,RESET,RESTRICT,RESULT,RETURN,RETURNED_LENGTH' +
675     ',RETURNED_OCTET_LENGTH,RETURNED_SQLSTATE,RETURNS,REVOKE,RIGHT,ROLE,ROLLBACK,ROLLUP,ROUTINE,ROUTINE_CATALOG' +
676     ',ROUTINE_NAME,ROUTINE_SCHEMA,ROW,ROWS,ROW_COUNT,RULE,SAVEPOINT,SCALE,SCHEMA,SCHEMA_NAME' +
677     ',SCOPE,SCROLL,SEARCH,SECOND,SECTION,SECURITY,SELECT,SELF,SENSITIVE,SEQUENCE,SERIALIZABLE,SERVER_NAME' +
678     ',SESSION,SET,SETOF,SETS,SHARE,SHOW,SIMILAR,SIMPLE,SIZE,SOURCE,SPACE' +
679     ',SPECIFIC,SPECIFICTYPE,SPECIFIC_NAME,SQLCODE,SQLERROR,SQLEXCEPTION,SQLSTATE,SQLWARNING' +
680     ',STABLE,START,STATE,STATEMENT,STATIC,STATISTICS,STDIN,STDOUT,STORAGE,STRICT,STRUCTURE' +
681     ',STYLE,SUBCLASS_ORIGIN,SUBLIST,SYMMETRIC,SYSID,SYSTEM,SYSTEM_USER,TABLE' +
682     ',TABLE_NAME,TEMP,TEMPLATE,TEMPORARY,TERMINATE,THAN,THEN,TIMEZONE_HOUR' +
683     ',TIMEZONE_MINUTE,TO,TOAST,TRAILING,TRANSACTION,TRANSACTIONS_COMMITTED,TRANSACTIONS_ROLLED_BACK' +
684     ',TRANSACTION_ACTIVE,TRANSFORM,TRANSFORMS,TRANSLATION,TREAT,TRIGGER_CATALOG' +
685     ',TRIGGER_NAME,TRIGGER_SCHEMA,TRUE,TRUNCATE,TRUSTED,TYPE,UNCOMMITTED,UNDER,UNENCRYPTED,UNION'+
686     ',UNIQUE,UNKNOWN,UNLISTEN,UNNAMED,UNNEST,UNTIL,UPDATE,USAGE,USER_DEFINED_TYPE_CATALOG' +
687     ',USER_DEFINED_TYPE_NAME,USER_DEFINED_TYPE_SCHEMA,USING,VACUUM,VALID,VALIDATOR,VALUE,VALUES' +
688     ',VARIABLE,VARYING,VERBOSE,VIEW,VOLATILE,WHEN,WHENEVER,WHERE,WITH,WITHOUT,WORK,WRITE,YEAR,ZONE';
689 
690   //Postgresql Functions
691   PostgresFunctions:String =
692     'abs,cbrt,ceil,ceiling,degrees,exp,floor,ln,log,mod,pi,power,radians,random,'+
693     'round,setseed,sign,sqrt,trunc,width_bucket,acos,asin,atan,atan2,cos,cot,'+
694     'sin,tan,bit_length,char_length,character_length,convert,lower,octet_length,'+
695     'overlay,position,substring,trim,upper,ascii,btrim,chr,decode,'+
696     'encode,initcap,length,lpad,ltrim,md5,pg_client_encoding,quote_ident,quote_literal,'+
697     'replace,rpad,rtrim,split_part,strpos,substr,to_ascii,to_hex,translate,get_byte,'+
698     'set_byte,get_bit,set_bit,to_char,to_date,'+
699     'to_timestamp,to_number,age,date_part,date_trunc,extract,now,'+
700     'timeofday,isfinite,area,box_intersect,center,diameter,height,isclosed,isopen,'+
701     'npoints,pclose,popen,radius,width,'+
702     'broadcast,'+
703     'host,masklen,set_masklen,netmask,hostmask,network,abbrev,family,nextval,'+
704     'currval,setval,coalesce,nullif,array_cat ,array_append ,array_prepend ,array_dims,'+
705     'array_lower ,array_upper ,array_to_string ,string_to_array ,avg,bit_and,bit_or,bool_and,'+
706     'bool_or,count,every,max,min,stddev,sum,variance,exists ,in ,some,'+
707     'all ,generate_series,current_database,current_schema,'+
708     'current_schemas,,inet_client_addr,inet_client_port,inet_server_addr,inet_server_port,'+
709     'version,has_table_privilege,has_database_privilege,'+
710     'has_function_privilege,has_language_privilege,'+
711     'has_schema_privilege,has_tablespace_privilege,'+
712     'pg_table_is_visible,pg_type_is_visible,pg_function_is_visible,pg_operator_is_visible,'+
713     'pg_opclass_is_visible,pg_conversion_is_visible,format_type,pg_get_viewdef,'+
714     'pg_get_ruledef,pg_get_indexdef,'+
715     'pg_get_triggerdef,pg_get_constraintdef,pg_get_expr,'+
716     'pg_get_userbyid,pg_get_serial_sequence,pg_tablespace_databases,obj_description,'+
717     'col_description,current_setting,set_config,pg_cancel_backend,pg_start_backup,pg_stop_backup,'+
718     'current_user,current_date,current_time,current_timestamp,localtime,localtimestamp,session_user,user';
719 
720   //Postgresql Types
721   PostgresTypes: String =
722     'smallint,integer,bigint,decimal,numeric,real,double,serial,bigserial,'+
723     'character,varchar,char,text,bytea,timestamp, interval,date,'+
724     'time,boolean,point,line,lseg,box,path,polygon,circle,cidr,inet,'+
725     'macaddr,BIT,bitvar,ARRAY,oid,regproc,regprocedure,regoper,regoperator,regclass,'+
726     'regtype,any,anyarray,anyelement,cstring,internal,language_handler,record,'+
727     'trigger,void,opaque,refcursor,binary,blob,int4,int2,int8,float,float4,float8';
728 
729   //Postgresql Exceptions
730   PostgresExceptions: String =
731     '$BODY$,SUCCESSFUL_COMPLETION,WARNING,DYNAMIC_RESULT_SETS_RETURNED,IMPLICIT_ZERO_BIT_PADDING,NULL_VALUE_ELIMINATED_IN_SET_FUNCTION,'+
732     'PRIVILEGE_NOT_GRANTED,PRIVILEGE_NOT_REVOKED,STRING_DATA_RIGHT_TRUNCATION,DEPRECATED_FEATURE,NO_DATA,NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED,'+
733     'SQL_STATEMENT_NOT_YET_COMPLETE,CONNECTION_EXCEPTION,CONNECTION_DOES_NOT_EXIST,CONNECTION_FAILURE,SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION,'+
734     'SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION,TRANSACTION_RESOLUTION_UNKNOWN,PROTOCOL_VIOLATION,TRIGGERED_ACTION_EXCEPTION,'+
735     'FEATURE_NOT_SUPPORTED,INVALID_TRANSACTION_INITIATION,LOCATOR_EXCEPTION,INVALID_LOCATOR_SPECIFICATION,INVALID_GRANTOR,INVALID_GRANT_OPERATION,'+
736     'INVALID_ROLE_SPECIFICATION,CARDINALITY_VIOLATION,DATA_EXCEPTION,ARRAY_SUBSCRIPT_ERROR,CHARACTER_NOT_IN_REPERTOIRE,DATETIME_FIELD_OVERFLOW,'+
737     'DIVISION_BY_ZERO,ERROR_IN_ASSIGNMENT,ESCAPE_CHARACTER_CONFLICT,INDICATOR_OVERFLOW,INTERVAL_FIELD_OVERFLOW,INVALID_ARGUMENT_FOR_LOGARITHM,'+
738     'INVALID_ARGUMENT_FOR_POWER_FUNCTION,INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION,INVALID_CHARACTER_VALUE_FOR_CAST,INVALID_DATETIME_FORMAT,'+
739     'INVALID_ESCAPE_CHARACTER,INVALID_ESCAPE_OCTET,INVALID_ESCAPE_SEQUENCE,INVALID_INDICATOR_PARAMETER_VALUE,INVALID_LIMIT_VALUE,'+
740     'INVALID_PARAMETER_VALUE,INVALID_REGULAR_EXPRESSION,INVALID_TIME_ZONE_DISPLACEMENT_VALUE,INVALID_USE_OF_ESCAPE_CHARACTER,'+
741     'MOST_SPECIFIC_TYPE_MISMATCH,NULL_VALUE_NOT_ALLOWED,NULL_VALUE_NO_INDICATOR_PARAMETER,NUMERIC_VALUE_OUT_OF_RANGE,STRING_DATA_LENGTH_MISMATCH,'+
742     'SUBSTRING_ERROR,TRIM_ERROR,UNTERMINATED_C_STRING,ZERO_LENGTH_CHARACTER_STRING,FLOATING_POINT_EXCEPTION,'+
743     'INVALID_TEXT_REPRESENTATION,INVALID_BINARY_REPRESENTATION,BAD_COPY_FILE_FORMAT,UNTRANSLATABLE_CHARACTER,INTEGRITY_CONSTRAINT_VIOLATION,'+
744     'RESTRICT_VIOLATION,NOT_NULL_VIOLATION,FOREIGN_KEY_VIOLATION,UNIQUE_VIOLATION,CHECK_VIOLATION,INVALID_CURSOR_STATE,INVALID_TRANSACTION_STATE,'+
745     'ACTIVE_SQL_TRANSACTION,BRANCH_TRANSACTION_ALREADY_ACTIVE,HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL,INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION,'+
746     'INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION,NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION,READ_ONLY_SQL_TRANSACTION,'+
747     'SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED,NO_ACTIVE_SQL_TRANSACTION,IN_FAILED_SQL_TRANSACTION,INVALID_SQL_STATEMENT_NAME,TRIGGERED_DATA_CHANGE_VIOLATION,'+
748     'INVALID_AUTHORIZATION_SPECIFICATION,DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST,DEPENDENT_OBJECTS_STILL_EXIST,INVALID_TRANSACTION_TERMINATION,'+
749     'SQL_ROUTINE_EXCEPTION,FUNCTION_EXECUTED_NO_RETURN_STATEMENT,MODIFYING_SQL_DATA_NOT_PERMITTED,PROHIBITED_SQL_STATEMENT_ATTEMPTED,READING_SQL_DATA_NOT_PERMITTED,'+
750     'INVALID_CURSOR_NAME,EXTERNAL_ROUTINE_EXCEPTION,CONTAINING_SQL_NOT_PERMITTED,'+
751     'EXTERNAL_ROUTINE_INVOCATION_EXCEPTION,INVALID_SQLSTATE_RETURNED,TRIGGER_PROTOCOL_VIOLATED,'+
752     'SRF_PROTOCOL_VIOLATED,SAVEPOINT_EXCEPTION,INVALID_SAVEPOINT_SPECIFICATION,INVALID_CATALOG_NAME,INVALID_SCHEMA_NAME,TRANSACTION_ROLLBACK,'+
753     'TRANSACTION_INTEGRITY_CONSTRAINT_VIOLATION,SERIALIZATION_FAILURE,STATEMENT_COMPLETION_UNKNOWN,DEADLOCK_DETECTED,SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION,'+
754     'SYNTAX_ERROR,INSUFFICIENT_PRIVILEGE,CANNOT_COERCE,GROUPING_ERROR,INVALID_FOREIGN_KEY,INVALID_NAME,NAME_TOO_LONG,RESERVED_NAME,DATATYPE_MISMATCH,'+
755     'INDETERMINATE_DATATYPE,WRONG_OBJECT_TYPE,UNDEFINED_COLUMN,UNDEFINED_FUNCTION,UNDEFINED_TABLE,UNDEFINED_PARAMETER,UNDEFINED_OBJECT,'+
756     'DUPLICATE_COLUMN,DUPLICATE_CURSOR,DUPLICATE_DATABASE,DUPLICATE_FUNCTION,DUPLICATE_PREPARED_STATEMENT,DUPLICATE_SCHEMA,DUPLICATE_TABLE,'+
757     'DUPLICATE_ALIAS,DUPLICATE_OBJECT,AMBIGUOUS_COLUMN,AMBIGUOUS_FUNCTION,AMBIGUOUS_PARAMETER,AMBIGUOUS_ALIAS,INVALID_COLUMN_REFERENCE,'+
758     'INVALID_COLUMN_DEFINITION,INVALID_CURSOR_DEFINITION,INVALID_DATABASE_DEFINITION,INVALID_FUNCTION_DEFINITION,INVALID_PREPARED_STATEMENT_DEFINITION,'+
759     'INVALID_SCHEMA_DEFINITION,INVALID_TABLE_DEFINITION,INVALID_OBJECT_DEFINITION,WITH_CHECK_OPTION_VIOLATION,INSUFFICIENT_RESOURCES,'+
760     'DISK_FULL,OUT_OF_MEMORY,TOO_MANY_CONNECTIONS,PROGRAM_LIMIT_EXCEEDED,STATEMENT_TOO_COMPLEX,TOO_MANY_COLUMNS,TOO_MANY_ARGUMENTS,'+
761     'OBJECT_NOT_IN_PREREQUISITE_STATE,OBJECT_IN_USE,CANT_CHANGE_RUNTIME_PARAM,LOCK_NOT_AVAILABLE,OPERATOR_INTERVENTION,QUERY_CANCELED,'+
762     'ADMIN_SHUTDOWN,CRASH_SHUTDOWN,CANNOT_CONNECT_NOW,IO_ERROR,UNDEFINED_FILE,DUPLICATE_FILE,CONFIG_FILE_ERROR,LOCK_FILE_EXISTS,'+
763     'PLPGSQL_ERROR,RAISE_EXCEPTION,INTERNAL_ERROR,DATA_CORRUPTED,INDEX_CORRUPTED';
764 
765 //---MS-SQL 7-------------------------------------------------------------------
766   // keywords
767   MSSQL7KW: string =
768     'ABSOLUTE,ADD,ALL,ALTER,ANY,AS,ASC,AUTHORIZATION,AVG,BACKUP,BEGIN,' +
769     'BETWEEN,BREAK,BROWSE,BULK,BY,CASCADE,CHECK,CHECKPOINT,CLOSE,CLUSTERED,' +
770     'COLUMN,COMMIT,COMMITTED,COMPUTE,CONFIRM,CONSTRAINT,CONTAINS,' +
771     'CONTAINSTABLE,CONTINUE,CONTROLROW,COUNT,CREATE,CROSS,CURRENT,' +
772     'CURRENT_DATE,CURRENT_TIME,CURSOR,DATABASE,DBCC,DEALLOCATE,DECLARE,' +
773     'DEFAULT,DELETE,DENY,DESC,DISK,DISTINCT,DISTRIBUTED,DOUBLE,DROP,DUMMY,' +
774     'DUMP,ELSE,END,ERRLVL,ERROREXIT,ESCAPE,EXCEPT,EXEC,EXECUTE,EXISTS,EXIT,' +
775     'FETCH,FILE,FILLFACTOR,FIRST,FLOPPY,FOR,FOREIGN,FREETEXT,FREETEXTTABLE,' +
776     'FROM,FULL,GLOBAL,GOTO,GRANT,GROUP,HAVING,HOLDLOCK,IDENTITY,IDENTITYCOL,' +
777     'IDENTITY_INSERT,IF,IN,INDEX,INNER,INSERT,INTERSECT,INTO,IS,ISOLATION,' +
778     'JOIN,KEY,KILL,LAST,LEFT,LEVEL,LIKE,LINENO,LOAD,MAX,MIN,MIRROREXIT,' +
779     'NATIONAL,NEXT,NOCHECK,NONCLUSTERED,NOT,NULL,OF,OFF,OFFSETS,ON,ONCE,' +
780     'ONLY,OPEN,OPENDATASOURCE,OPENQUERY,OPENROWSET,OPTION,OR,ORDER,OUTER,' +
781     'OVER,PERCENT,PERM,PERMANENT,PIPE,PLAN,PRECISION,PREPARE,PRIMARY,PRINT,' +
782     'PRIOR,PRIVILEGES,PROC,PROCEDURE,PROCESSEXIT,PUBLIC,RAISERROR,READ,' +
783     'READTEXT,RECONFIGURE,REFERENCES,RELATIVE,REPEATABLE,REPLICATION,RESTORE,' +
784     'RESTRICT,RETURN,REVOKE,RIGHT,ROLLBACK,ROWCOUNT,ROWGUIDCOL,RULE,SAVE,' +
785     'SCHEMA,SELECT,SERIALIZABLE,SET,SETUSER,SHUTDOWN,SOME,STATISTICS,SUM,' +
786     'TABLE,TAPE,TEMP,TEMPORARY,TEXTSIZE,THEN,TO,TOP,TRAN,TRANSACTION,TRIGGER,' +
787     'TRUNCATE,TSEQUAL,UNCOMMITTED,UNION,UNIQUE,UPDATE,UPDATETEXT,USE,USER,' +
788     'VALUES,VARYING,VIEW,WAITFOR,WHEN,WHERE,WHILE,WITH,WORK,WRITETEXT';
789 
790   // functions
791   MSSQL7Functions: string =
792     '@@CONNECTIONS,@@CPU_BUSY,@@CURSOR_ROWS,@@DATEFIRST,@@DBTS,@@ERROR,' +
793     '@@FETCH_STATUS,@@IDENTITY,@@IDLE,@@IO_BUSY,@@LANGID,@@LANGUAGE,' +
794     '@@LOCK_TIMEOUT,@@MAX_CONNECTIONS,@@MAX_PRECISION,@@NESTLEVEL,@@OPTIONS,' +
795     '@@PACKET_ERRORS,@@PACK_RECEIVED,@@PACK_SENT,@@PROCID,@@REMSERVER,' +
796     '@@ROWCOUNT,@@SERVERNAME,@@SERVICENAME,@@SPID,@@TEXTSIZE,@@TIMETICKS,' +
797     '@@TOTAL_ERRORS,@@TOTAL_READ,@@TOTAL_WRITE,@@TRANCOUNT,@@VERSION,ABS,' +
798     'ACOS,AND,APP_NAME,ASCII,ASIN,ATAN,ATN2,CASE,CAST,CEILING,CHARINDEX,' +
799     'COALESCE,COLUMNPROPERTY,COL_LENGTH,COL_NAME,CONVERT,COS,COT,' +
800     'CURRENT_TIMESTAMP,CURRENT_USER,CURSOR_STATUS,DATABASEPROPERTY,' +
801     'DATALENGTH,DATEADD,DATEDIFF,DATENAME,DATEPART,DAY,DB_ID,DB_NAME,' +
802     'DEGREES,DIFFERENCE,EXP,FILEGROUPPROPERTY,FILEGROUP_ID,FILEGROUP_NAME,' +
803     'FILEPROPERTY,FILE_ID,FILE_NAME,FLOOR,FORMATMESSAGE,' +
804     'FULLTEXTCATALOGPROPERTY,FULLTEXTSERVICEPROPERTY,GETANSINULL,GETDATE,' +
805     'HOST_ID,HOST_NAME,IDENT_INCR,IDENT_SEED,INDEXPROPERTY,INDEX_COL,' +
806     'ISDATE,ISNULL,ISNUMERIC,IS_MEMBER,IS_SRVROLEMEMBER,LEN,LOG,LOG10,LOWER,' +
807     'LTRIM,MONTH,NEWID,NULLIF,OBJECTPROPERTY,OBJECT_ID,OBJECT_NAME,PARSENAME,' +
808     'PATINDEX,PERMISSIONS,PI,POWER,QUOTENAME,RADIANS,RAND,REPLACE,REPLICATE,' +
809     'REVERSE,ROUND,RTRIM,SESSION_USER,SIGN,SIN,SOUNDEX,SPACE,SQRT,SQUARE,' +
810     'STATS_DATE,STR,STUFF,SUBSTRING,SUSER_ID,SUSER_NAME,SUSER_SID,' +
811     'SUSER_SNAME,SYSTEM_USER,TAN,TEXTPTR,TEXTVALID,TYPEPROPERTY,UNICODE,' +
812     'UPPER,USER_ID,USER_NAME,YEAR';
813 
814   // types
815   MSSQL7Types: string =
816     'BINARY,BIT,CHAR,DATETIME,DECIMAL,FLOAT,IMAGE,INT,MONEY,NCHAR,NTEXT,' +
817     'NUMERIC,NVARCHAR,REAL,SMALLDATETIME,SMALLINT,SMALLMONEY,SYSNAME,TEXT,' +
818     'TIMESTAMP,TINYINT,UNIQUEIDENTIFIER,VARBINARY,VARCHAR';
819 
820 //---MS-SQL2K-------------------------------------------------------------------
821   // keywords
822   MSSQL2000KW =
823     'ADD,ALL,ALTER,AND,ANY,AS,ASC,AUTHORIZATION,BACKUP,' +
824     'BEGIN,BETWEEN,BREAK,BROWSE,BULK,BY,CASCADE,CASE,' +
825     'CHECK,CHECKPOINT,CLOSE,CLUSTERED,COLLATE,' +
826     'COLUMN,COMMIT,COMPUTE,CONSTRAINT,CONTAINS,CONTAINSTABLE,' +
827     'CONTINUE,CREATE,CROSS,CURRENT,CURSOR,DATABASE,' +
828     'DBCC,DEALLOCATE,DECLARE,DEFAULT,DELETE,DENY,DESC,DISK,' +
829     'DISTINCT,DISTRIBUTED,DOUBLE,DROP,DUMMY,DUMP,ELSE,END,' +
830     'ERRLVL,ESCAPE,EXCEPT,EXEC,EXECUTE,EXISTS,EXIT,FETCH,FILE,' +
831     'FILLFACTOR,FOR,FOREIGN,FORMSOF,FREETEXT,FREETEXTTABLE,FROM,FULL,' +
832     'FUNCTION,GOTO,GRANT,GROUP,HAVING,HOLDLOCK,IDENTITY,' +
833     'IDENTITYCOL,IDENTITY_INSERT,IF,IN,INFLECTIONAL,INDEX,INNER,INSERT,' +
834     'INTERSECT,INTO,IS,ISABOUT,JOIN,KEY,KILL,LEFT,LIKE,LINENO,LOAD,' +
835     'NATIONAL,NOCHECK,NONCLUSTERED,NOT,NULL,NULLIF,OF,OFF,' +
836     'OFFSETS,ON,OPEN,OPENDATASOURCE,OPENQUERY,OPENROWSET,OPENXML,' +
837     'OPTION,OR,ORDER,OUTER,OVER,PERCENT,PLAN,PRECISION,' +
838     'PRIMARY,PRINT,PROC,PROCEDURE,PUBLIC,RAISERROR,READ,' +
839     'READTEXT,RECONFIGURE,REFERENCES,REPLICATION,RESTORE,' +
840     'RESTRICT,RETURN,REVOKE,RIGHT,ROLLBACK,ROWCOUNT,ROWGUIDCOL,' +
841     'RULE,SAVE,SCHEMA,SELECT,SESSION_USER,SET,SETUSER,SHUTDOWN,' +
842     'SOME,STATISTICS,TABLE,TEXTSIZE,THEN,TO,TOP,TRAN,TRANSACTION,' +
843     'TRIGGER,TRUNCATE,TSEQUAL,UNION,UNIQUE,UPDATE,UPDATETEXT,' +
844     'USE,USER,VALUES,VARYING,VIEW,WAITFOR,WEIGHT,WHEN,WHERE,WHILE,' +
845     'WITH,WRITETEXT';
846 
847   // functions
848   MSSQL2000Functions =
849     '@@CONNECTIONS,@@CPU_BUSY,@@CURSOR_ROWS,@@DATEFIRST,@@DBTS,@@ERROR,' +
850     '@@FETCH_STATUS,@@IDENTITY,@@IDLE,@@IO_BUSY,@@LANGID,@@LANGUAGE,' +
851     '@@LOCK_TIMEOUT,@@MAX_CONNECTIONS,@@MAX_PRECISION,@@NESTLEVEL,@@OPTIONS,' +
852     '@@PACKET_ERRORS,@@PACK_RECEIVED,@@PACK_SENT,@@PROCID,@@REMSERVER,' +
853     '@@ROWCOUNT,@@SERVERNAME,@@SERVICENAME,@@SPID,@@TEXTSIZE,@@TIMETICKS,' +
854     '@@TOTAL_ERRORS,@@TOTAL_READ,@@TOTAL_WRITE,@@TRANCOUNT,@@VERSION,' +
855     'ABS,ACOS,APP_NAME,ASCII,ASIN,ATAN,ATN2,AVG,BINARY_CHECKSUM,CAST,' +
856     'CEILING,CHARINDEX,CHECKSUM,CHECKSUM_AGG,COALESCE,COLLATIONPROPERTY,' +
857     'COLUMNPROPERTY,COL_LENGTH,COL_NAME,CONVERT,COS,COT,COUNT,' +
858     'COUNT_BIG,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,' +
859     'CURRENT_USER,CURSOR_STATUS,DATABASEPROPERTY,DATABASEPROPERTYEX,' +
860     'DATALENGTH,DATEADD,DATEDIFF,DATENAME,DATEPART,DAY,DB_ID,DB_NAME,DEGREES,' +
861     'DIFFERENCE,EXP,FILEGROUPPROPERTY,FILEGROUP_ID,FILEGROUP_NAME,' +
862     'FILEPROPERTY,FILE_ID,FILE_NAME,FLOOR,fn_helpcollations,' +
863     'fn_listextendedproperty,fn_servershareddrives,fn_trace_geteventinfo,' +
864     'fn_trace_getfilterinfo,fn_trace_getinfo,fn_trace_gettable,' +
865     'fn_virtualfilestats,FORMATMESSAGE,FULLTEXTCATALOGPROPERTY,' +
866     'FULLTEXTSERVICEPROPERTY,GETANSINULL,GETDATE,GETUTCDATE,GROUPING,' +
867     'HAS_DBACCESS,HOST_ID,HOST_NAME,IDENT_CURRENT,IDENT_INCR,IDENT_SEED,' +
868     'INDEXKEY_PROPERTY,INDEXPROPERTY,INDEX_COL,ISDATE,ISNULL,ISNUMERIC,' +
869     'IS_MEMBER,IS_SRVROLEMEMBER,LEN,LOG,LOG10,LOWER,LTRIM,MAX,MIN,MONTH,' +
870     'NEWID,OBJECTPROPERTY,OBJECT_ID,OBJECT_NAME,PARSENAME,PATINDEX,' +
871     'PERMISSIONS,PI,POWER,QUOTENAME,RADIANS,RAND,REPLACE,REPLICATE,REVERSE,' +
872     'ROUND,ROWCOUNT_BIG,RTRIM,SCOPE_IDENTITY,SERVERPROPERTY,SESSIONPROPERTY,' +
873     'SIGN,SIN,SOUNDEX,SPACE,SQL_VARIANT_PROPERTY,SQRT,SQUARE,' +
874     'STATS_DATE,STDEV,STDEVP,STR,STUFF,SUBSTRING,SUM,SUSER_SID,SUSER_SNAME,' +
875     'SYSTEM_USER,TAN,TEXTPTR,TEXTVALID,TYPEPROPERTY,UNICODE,UPPER,' +
876     'USER_ID,USER_NAME,VAR,VARP,YEAR';
877 
878   // types
879   MSSQL2000Types =
880     'bigint,binary,bit,char,character,datetime,' +
881     'dec,decimal,float,image,int,' +
882     'integer,money,nchar,ntext,nvarchar,real,' +
883     'rowversion,smalldatetime,smallint,smallmoney,' +
884     'sql_variant,sysname,text,timestamp,tinyint,uniqueidentifier,' +
885     'varbinary,varchar';
886 
887 //---Interbase 6----------------------------------------------------------------
888   // functions
889   Interbase6Functions = 'AVG,CAST,COUNT,GEN_ID,MAX,MIN,SUM,UPPER';
890 
891   // keywords
892   Interbase6KW: string = 'ACTIVE,ADD,AFTER,ALL,ALTER,AND,ANY,AS,ASC,' +
893     'ASCENDING,AT,AUTO,AUTODDL,BASED,BASENAME,BASE_NAME,BEFORE,BEGIN,BETWEEN,' +
894     'BLOBEDIT,BUFFER,BY,CACHE,CHARACTER_LENGTH,CHAR_LENGTH,CHECK,' +
895     'CHECK_POINT_LEN,CHECK_POINT_LENGTH,COLLATE,COLLATION,COLUMN,COMMIT,' +
896     'COMMITED,COMPILETIME,COMPUTED,CLOSE,CONDITIONAL,CONNECT,CONSTRAINT,' +
897     'CONTAINING,CONTINUE,CREATE,CURRENT,CURRENT_DATE,CURRENT_TIME,' +
898     'CURRENT_TIMESTAMP,CURSOR,DATABASE,DAY,DB_KEY,DEBUG,DEC,DECLARE,DEFAULT,' +
899     'DELETE,DESC,DESCENDING,DESCRIBE,DESCRIPTOR,DISCONNECT,DISTINCT,DO,' +
900     'DOMAIN,DROP,ECHO,EDIT,ELSE,END,ENTRY_POINT,ESCAPE,EVENT,EXCEPTION,' +
901     'EXECUTE,EXISTS,EXIT,EXTERN,EXTERNAL,EXTRACT,FETCH,FILE,FILTER,FOR,' +
902     'FOREIGN,FOUND,FROM,FULL,FUNCTION,GDSCODE,GENERATOR,GLOBAL,GOTO,GRANT,' +
903     'GROUP,GROUP_COMMIT_WAIT,GROUP_COMMIT_WAIT_TIME,HAVING,HELP,HOUR,IF,' +
904     'IMMEDIATE,IN,INACTIVE,INDEX,INDICATOR,INIT,INNER,INPUT,INPUT_TYPE,' +
905     'INSERT,INT,INTO,IS,ISOLATION,ISQL,JOIN,KEY,LC_MESSAGES,LC_TYPE,LEFT,' +
906     'LENGTH,LEV,LEVEL,LIKE,LOGFILE,LOG_BUFFER_SIZE,LOG_BUF_SIZE,LONG,MANUAL,' +
907     'MAXIMUM,MAXIMUM_SEGMENT,MAX_SEGMENT,MERGE,MESSAGE,MINIMUM,MINUTE,' +
908     'MODULE_NAME,MONTH,NAMES,NATIONAL,NATURAL,NCHAR,NO,NOAUTO,NOT,NULL,' +
909     'NUM_LOG_BUFFS,NUM_LOG_BUFFERS,OCTET_LENGTH,OF,ON,ONLY,OPEN,OPTION,OR,' +
910     'ORDER,OUTER,OUTPUT,OUTPUT_TYPE,OVERFLOW,PAGE,PAGELENGTH,PAGES,PAGE_SIZE,' +
911     'PARAMETER,PASSWORD,PLAN,POSITION,POST_EVENT,PRECISION,PREPARE,PROCEDURE,' +
912     'PROTECTED,PRIMARY,PRIVILEGES,PUBLIC,QUIT,RAW_PARTITIONS,READ,REAL,' +
913     'RECORD_VERSION,REFERENCES,RELEASE,RESERV,RESERVING,RETAIN,RETURN,' +
914     'RETURNING_VALUES,RETURNS,REVOKE,RIGHT,ROLLBACK,RUNTIME,SCHEMA,SECOND,' +
915     'SEGMENT,SELECT,SET,SHADOW,SHARED,SHELL,SHOW,SINGULAR,SIZE,SNAPSHOT,SOME,' +
916     'SORT,SQL,SQLCODE,SQLERROR,SQLWARNING,STABILITY,STARTING,STARTS,' +
917     'STATEMENT,STATIC,STATISTICS,SUB_TYPE,SUSPEND,TABLE,TERMINATOR,THEN,TO,' +
918     'TRANSACTION,TRANSLATE,TRANSLATION,TRIGGER,TRIM,TYPE,UNCOMMITTED,UNION,' +
919     'UNIQUE,UPDATE,USER,USING,VALUE,VALUES,VARIABLE,VARYING,VERSION,VIEW,' +
920     'WAIT,WEEKDAY,WHEN,WHENEVER,WHERE,WHILE,WITH,WORK,WRITE,YEAR,YEARDAY';
921 
922   // types
923   Interbase6Types = 'BLOB,CHAR,CHARACTER,DATE,DECIMAL,DOUBLE,FLOAT,INTEGER,' +
924     'NUMERIC,SMALLINT,TIME,TIMESTAMP,VARCHAR';
925 
926 //---MySQL----------------------------------------------------------------------
927   // keywords
928   MySqlKW: string = 'ACTION,AFTER,AGAINST,AGGREGATE,ALL,ALTER,ANALYZE,AND,AS,' +
929     'ASC,AUTO_INCREMENT,AVG_ROW_LENGTH,BACKUP,BEGIN,BENCHMARK,BETWEEN,BINARY,' +
930     'BIT,BOOL,BOTH,BY,CASCADE,CHANGE,CHARACTER,CHECK,CHECKSUM,COLUMN,COLUMNS,' +
931     'COMMENT,COMMIT,CONSTRAINT,CREATE,CROSS,DATA,DATABASES,DEC,DEFAULT,' +
932     'DELAYED,DELAY_KEY_WRITE,DELETE,DESC,DESCRIBE,DISTINCT,DISTINCTROW,DROP,' +
933     'ELSE,ENCLOSED,END,ESCAPE,ESCAPED,EXISTS,EXPLAIN,FIELDS,FILE,FIRST,' +
934     'FLOAT4,FLOAT8,FLUSH,FOR,FOREIGN,FROM,FULL,FULLTEXT,FUNCTION,GLOBAL,GRANT,' +
935     'GRANTS,GROUP,HAVING,HEAP,HIGH_PRIORITY,HOSTS,IDENTIFIED,IGNORE,' +
936     'INDEX,INFILE,INNER,INT1,INT2,INT3,INT4,INT8,INTO,IS,ISAM,JOIN,KEY,' +
937     'KEYS,KILL,LEADING,LIKE,LIMIT,LINES,LOAD,LOCAL,LOCK,LOGS,LONG,' +
938     'LOW_PRIORITY,MATCH,MAX_ROWS,MIDDLEINT,MIN_ROWS,MODIFY,MYISAM,' +
939     'NATURAL,NO,NOT,NULL,OPTIMIZE,OPTION,OPTIONALLY,ON,OPEN,OR,ORDER,OUTER,' +
940     'OUTFILE,PACK_KEYS,PARTIAL,PRECISION,PRIMARY,PRIVILEGES,PROCEDURE,' +
941     'PROCESS,PROCESSLIST,READ,REFERENCES,REGEXP,RELOAD,RENAME,REPAIR,' +
942     'RESTRICT,RESTORE,RETURNS,REVOKE,RLIKE,ROLLBACK,ROW,ROWS,SELECT,SHOW,' +
943     'SHUTDOWN,SONAME,SQL_BIG_RESULT,SQL_BIG_SELECTS,SQL_BIG_TABLES,' +
944     'SQL_LOG_OFF,SQL_LOG_UPDATE,SQL_LOW_PRIORITY_UPDATES,SQL_SELECT_LIMIT,' +
945     'SQL_SMALL_RESULT,SQL_WARNINGS,STARTING,STATUS,STRAIGHT_JOIN,TABLE,' +
946     'TABLES,TEMPORARY,TERMINATED,THEN,TO,TRAILING,TRANSACTION,TYPE,UNIQUE,' +
947     'UNLOCK,UNSIGNED,UPDATE,USAGE,USE,USING,VALUES,VARBINARY,VARCHAR,' +
948     'VARIABLES,VARYING,WHERE,WITH,WRITE,ZEROFILL';
949 
950   // types
951   MySqlTypes: string = 'TINYINT,SMALLINT,MEDIUMINT,INT,INTEGER,BIGINT,FLOAT,' +
952     'DOUBLE,REAL,DECIMAL,NUMERIC,DATE,DATETIME,TIMESTAMP,TIME,YEAR,CHAR,' +
953     'NATIONAL,TINYBLOB,TINYTEXT,TEXT,BLOB,MEDIUMBLOB,MEDIUMTEXT,LONGBLOB,' +
954     'LONGTEXT,ENUM,SET,STRING';
955 
956   // functions
957   MySqlFunctions: string = 'ABS,ACOS,ASCII,ADD,ADDDATE,ASIN,ATAN,ATAN2,AVG,' +
958     'BIN,BIT_AND,BIT_COUNT,BIT_OR,CASE,CHARACTER_LENGTH,CEILING,' +
959     'CONNECTION_ID,CHAR_LENGTH,COALESCE,CONCAT,CONV,COS,COT,COUNT,' +
960     'CURDATE,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURTIME,DATABASE,' +
961     'DATE_ADD,DATE_FORMAT,DATE_SUB,DAY,DAYNAME,DAYOFMONTH,DAYOFWEEK,' +
962     'DAYOFYEAR,DAY_HOUR,DAY_MINUTE,DAY_SECOND,DECODE,DEGREES,ELT,ENCODE,' +
963     'ENCRYPT,EXP,EXPORT_SET,FIELD,FIND_IN_SET,FLOOR,FORMAT,FROM_DAYS,' +
964     'FROM_UNIXTIME,GET_LOCK,GREATEST,HEX,HOUR,HOUR_MINUTE,HOUR_SECOND,IF,' +
965     'IFNULL,IN,INET_NTOA,INET_ATON,INSERT,INSERT_ID,INSTR,INTERVAL,ISNULL,' +
966     'LAST_INSERT_ID,LCASE,LEAST,LEFT,LENGTH,LOAD_FILE,LOCATE,LOG,LOG10,LOWER,' +
967     'LPAD,LTRIM,MAKE_SET,MASTER_POS_WAIT,MAX,MD5,MID,MIN,MINUTE,' +
968     'MINUTE_SECOND,MOD,MONTH,MONTHNAME,NOW,NULLIF,OCT,OCTET_LENGTH,ORD,' +
969     'PASSWORD,PERIOD_ADD,PERIOD_DIFF,PI,POSITION,POW,POWER,QUARTER,RADIANS,' +
970     'RAND,RELEASE_LOCK,REPEAT,REPLACE,REVERSE,RIGHT,ROUND,RPAD,RTRIM,SECOND,' +
971     'SEC_TO_TIME,SESSION_USER,SIGN,SIN,SOUNDEX,SPACE,SQRT,STD,STDDEV,STRCMP,' +
972     'SUBDATE,SUBSTRING,SUBSTRING_INDEX,SUM,SYSDATE,SYSTEM_USER,TAN,' +
973     'TIME_FORMAT,TIME_TO_SEC,TO_DAYS,TRIM,TRUNCATE,UCASE,UNIX_TIMESTAMP,' +
974     'UPPER,USER,VERSION,WEEK,WEEKDAY,WHEN,YEARWEEK,YEAR_MONTH';
975 
976 {begin}                                                                         // JJV 2000-11-16
977 //---Ingres---------------------------------------------------------------------
978   // keywords
979   IngresKW: string =
980     'ABORT,ACTIVATE,ADD,ADDFORM,AFTER,AGGREGATE,ALL,ALTER,AND,APPEND,ARRAY,' +
981     'AS,ASC,AT,AUDIT_LOG,AUTHORIZATION,AUTOCOMMIT,AVGU,BEFORE,BEGIN,BETWEEN,' +
982     'BREAKDISPLAY,BY,BYREF,CACHE,CALL,CALLFRAME,CALLPROC,CASCADE,CHECK,CLEAR,' +
983     'CLEARROW,CLOSE,COLUMN,COMMAND,COMMENT,COMMIT,CONNECT,CONSTRAINT,' +
984     'CONTINUE,COPY,COUNTU,CPUFACTOR,CREATE,CURRENT,CURRENT_USER,CURSOR,DATA,' +
985     'DATAHANDLER,DATE_FORMAT,DBEVENT,DDL_CONCURRENCY,DEADLOCK,DECLARE,' +
986     'DEFAULT,DEFERRED,DEFINE,DELETE,DELETEROW,DESC,DESCRIBE,DESCRIPTOR,' +
987     'DESTROY,DIRECT,DISABLE,DISCONNECT,DISPLAY,DISTINCT,DISTRIBUTE,DO,DOWN,' +
988     'DROP,ELSE,ELSEIF,ENABLE,END,ENDDATA,ENDDISPLAY,ENDFORMS,ENDIF,ENDLOOP,' +
989     'ENDRETRIEVE,ENDSELECT,ENDWHILE,ERROR,ESCAPE,EXCLUDE,EXCLUDING,EXEC,' +
990     'EXECUTE,EXISTS,EXIT,FETCH,FIELD,FINALIZE,FOR,FOREIGN,FORMDATA,FORMINIT,' +
991     'FORMS,FROM,FULL,GET,GETFORM,GETOPER,GETROW,GLOBAL,GOTO,GRANT,GRANTED,' +
992     'HAVING,HELP,HELP_FORMS,HELP_FRS,HELPFILE,IDENTIFIED,IF,IIMESSAGE,' +
993     'IIPRINTF,IIPROMPT,IISTATEMENT,IMMEDIATE,IMPORT,IN,INCLUDE,INDEX,' +
994     'INDICATOR,INGRES,INITIALIZE,INITTABLE,INNER,INQUIRE_EQUEL,INQUIRE_FORMS,' +
995     'INQUIRE_FRS,INQUIRE_INGRES,INSERT,INSERTROW,INSTALLATION,INTEGRITY,INTO,' +
996     'IO_TRACE,IS,J_FREESZ1,J_FREESZ2,J_FREESZ3,J_FREESZ4,J_SORTBUFSZ,' +
997     'JCPUFACTOR,JOIN,JOINOP,JOURNALING,KEY,LEVEL,LIKE,LINK,LOADTABLE,LOCAL,' +
998     'LOCATION,LOCK_TRACE,LOG_TRACE,LOGDBEVENTS,LOGGING,MAXCOST,MAXCPU,' +
999     'MAXPAGE,MENUITEM,MESSAGE,MODE,MODIFY,MODULE,MONEY_FORMAT,MONEY_PREC,' +
1000     'MOVE,NATURAL,NEXT,NODEADLOCK,NOECHO,NOIO_TRACE,NOJIONOP,NOJOURNALING,' +
1001     'NOLOCK_TRACE,NOLOG_TRACE,NOLOGDBEVENTS,NOLOGGING,NOMAXCOST,NOMAXCPU,' +
1002     'NOMAXIO,NOMAXPAGE,NOMAXQUERY,NOMAXROW,NOOPTIMIZEONLY,NOPRINTDBEVENTS,' +
1003     'NOPRINTQRY,NOPRINTRULES,NOQEP,NORULES,NOSQL,NOSTATISTICS,NOT,NOTRACE,' +
1004     'NULL,OF,ON,ONLY,OPEN,OPTIMIZEONLY,OPTION,OR,ORDER,OUT,PARAM,PERMIT,' +
1005     'PREPARE,PRESERVE,PRIMARY,PRINT,PRINTDBEVENTS,PRINTQRY,PRINTSCREEN,' +
1006     'PRIVILEGES,PROCEDURE,PROMPT,PUBLIC,PUT,PUTFORM,PUTOPER,PUTROW,QBUFSIZE,' +
1007     'QEP,QRY,QUALIFICATION,QUERY_SIZE,RAISE,RANGE,READONLY,REDISPLAY,' +
1008     'REFERENCES,REFERENCING,REGISTER,RELOCATE,REMOVE,RENAME,REPEAT,REPEATED,' +
1009     'REPLACE,REPLICATE,RESTRICT,RESULT_STRUCTURE,RESUME,RET_INTO,RETRIEVE,' +
1010     'RETURN,RETURNING,REVOKE,ROLLBACK,ROWS,RULE,RUN,SAVE,SAVEPOINT,SCHEMA,' +
1011     'SCREEN,SCROLL,SCROLLDOWN,SCROLLUP,SECTION,SECURITY_ALARM,SECURITY_AUDIT,' +
1012     'SELECT,SESSION,SET,SET_4GL,SET_EQUAL,SET_FORMS,SET_FRS,SET_INGRES,' +
1013     'SET_SQL,SHORT_REMARK,SLEEP,SOME,SORT,SORTBUFSIZE,SQL,STATISTICS,STOP,' +
1014     'SUBMENU,SUMU,SYNONYM,SYSTEM,TABLE,TABLEDATA,TEWMPORARY,THEN,TO,TRACE,' +
1015     'TRANSACTION,TYPE,UNION,UNIQUE,UNLOADTABLE,UNTIL,UP,UPDATE,USER,USING,' +
1016     'VALIDATE,VALIDROW,VALUES,VIEW,WHEN,WHENEVER,WHERE,WHILE,WITH,WORK';
1017 
1018   // types
1019   IngresTypes: string =
1020     'BYTE,C,CHAR,CHARACTER,DATE,DECIMAL,FLOAT,FLOAT4,FLOAT8,INTEGER,INTEGER1,' +
1021     'INTEGER2,INTEGER4,LONG,MONEY,OBJECT_KEY,SECURITY_LABEL,SHORT,SMALLINT,' +
1022     'TABLE_KEY,TEXT,VARCHAR,VARYING';
1023 
1024   // functions
1025   IngresFunctions: string =
1026     '_BINTIM,_CPU_MS,_DATE,_DIO_CNT,_ET_SEC,_PFAULT_CNT,_TIME,_VERSION,ABS,' +
1027     'ANY,ATAN,AUTOCOMMIT_STATE,AVG,BIOCNT,CHAREXTRACT,COLLATION,CONCAT,' +
1028     'CONNECT_TIME_LIMIT,COS,COUNT,CREATE_PROCEDURE,CREATE_TABLE,DATABASE,' +
1029     'DATE_GMT,DATE_PART,DATE_TRUNC,DB_ADMIN,DB_DELIMITED_CASE,DB_NAME_CASE,' +
1030     'DBA,DBMS_BIO,DBMS_CPU,DBMS_DIO,DBMSINFO,DOW,EXP,FLATTEN_AGGREGATE,' +
1031     'FLATTEN_NONE,FLATTEN_OPTIMIZE,FLATTEN_SINGLETON,GROUP,HEX,' +
1032     'IDLE_TIME_LIMIT,IFNULL,INITIAL_USER,INQUIRE_SQL,INT1,INT2,INT4,INTERVAL,' +
1033     'LANGUAGE,LEFT,LENGTH,LOCATE,LOCKMODE,LOG,LONG_BYTE,LONG_VARCHAR,' +
1034     'LOWERCASE,MAX,MAXCONNECT,MAXIDLE,MAXIO,MAXQUERY,MAXROW,MIN,MOD,NOTRIM,' +
1035     'ON_ERROR_STATE,PAD,QUERY_IO_LIMIT,QUERY_LANGUAGE,QUERY_ROW_LIMIT,RIGHT,' +
1036     'ROLE,SECURITY_AUDIT_LOG,SECURITY_AUDIT_STATE,SECURITY_PRIV,' +
1037     'SELECT_SYSCAT,SERVER_CLASS,SESSION_ID,SESSION_PRIORITY,' +
1038     'SESSION_PRIORITY_LIMIT,SESSION_PRIV,SESSION_SECLABEL,SESSION_USER,SHIFT,' +
1039     'SIN,SIZE,SQRT,SQUEEZE,SUM,SYSTEM_USER,TABLE_STATISTICS,TERMINAL,' +
1040     'TRANSACTION_STATE,TRIM,UPDATE_ROWCNT,UPDATE_SYSCAT,UPPERCASE,USERNAME,' +
1041     'VARBYTE';
1042 {end}                                                                           // JJV 2000-11-16
1043 
1044 procedure MakeIdentTable;
1045 var
1046   c: char;
1047 begin
1048   FillChar(Identifiers, SizeOf(Identifiers), 0);
1049   for c := 'a' to 'z' do
1050     Identifiers[c] := TRUE;
1051   for c := 'A' to 'Z' do
1052     Identifiers[c] := TRUE;
1053   for c := '0' to '9' do
1054     Identifiers[c] := TRUE;
1055   Identifiers['_'] := TRUE;
1056   Identifiers['#'] := TRUE;                                                     // DJLP 2000-09-05
1057   Identifiers['$'] := TRUE;                                                     // DJLP 2000-09-05
1058 
1059   FillChar(mHashTable, SizeOf(mHashTable), 0);
1060   mHashTable['_'] := 1;
1061   for c := 'a' to 'z' do
1062     mHashTable[c] := 2 + Ord(c) - Ord('a');
1063   for c := 'A' to 'Z' do
1064     mHashTable[c] := 2 + Ord(c) - Ord('A');
1065 
1066   Move(Identifiers, IdentifiersMSSQL7, SizeOf(Identifiers));
1067   Move(mHashTable, mHashTableMSSQL7, SizeOf(mHashTable));
1068   IdentifiersMSSQL7['@'] := TRUE;
1069   mHashTableMSSQL7['@'] := mHashTableMSSQL7['Z'] + 1;
1070 end;
1071 
KeyHashnull1072 function TSynSQLSyn.KeyHash(ToHash: PChar): Integer;
1073 var
1074   Start: PChar;
1075 begin
1076   Result := 0;
1077   Start := ToHash;
1078   while fIdentifiersPtr^[ToHash^] do begin
1079 
1080     Result := (2 * Result + fmHashTablePtr^[ToHash^]) and $FFFFFF;
1081     inc(ToHash);
1082   end;
1083   Result := Result and $FF; // 255
1084   fStringLen := ToHash - Start;
1085 end;
1086 
KeyCompnull1087 function TSynSQLSyn.KeyComp(const aKey: string): Boolean;
1088 var
1089   i: integer;
1090   pKey1, pKey2: PChar;
1091 begin
1092   pKey1 := fToIdent;
1093   // Note: fStringLen is always > 0 !
1094   pKey2 := pointer(aKey);
1095   for i := 1 to fStringLen do
1096   begin
1097     if mHashTable[pKey1^] <> mHashTable[pKey2^] then
1098     begin
1099       Result := FALSE;
1100       exit;
1101     end;
1102     Inc(pKey1);
1103     Inc(pKey2);
1104   end;
1105   Result := TRUE;
1106 end;
1107 
TSynSQLSyn.IdentKindnull1108 function TSynSQLSyn.IdentKind(MayBe: PChar): TtkTokenKind;
1109 var
1110   Entry: TSynHashEntry;
1111 begin
1112   fToIdent := MayBe;
1113   Entry := fKeywords[KeyHash(MayBe)];
1114   while Assigned(Entry) do begin
1115     if Entry.KeywordLen > fStringLen then
1116       break
1117     else if Entry.KeywordLen = fStringLen then
1118       if KeyComp(Entry.Keyword) then begin
1119         Result := TtkTokenKind(Entry.Kind);
1120         exit;
1121       end;
1122     Entry := Entry.Next;
1123   end;
1124   Result := tkIdentifier;
1125 end;
1126 
1127 procedure TSynSQLSyn.MakeMethodTables;
1128 var
1129   I: Char;
1130 begin
1131   for I := #0 to #255 do
1132     case I of
1133        #0: fProcTable[I] := @NullProc;
1134       #10: fProcTable[I] := @LFProc;
1135       #13: fProcTable[I] := @CRProc;
1136       #39: fProcTable[I] := @AsciiCharProc;
1137       '=': fProcTable[I] := @EqualProc;
1138       '>': fProcTable[I] := @GreaterProc;
1139       '<': fProcTable[I] := @LowerProc;
1140       '-': fProcTable[I] := @MinusProc;
1141       '|': fProcTable[I] := @OrSymbolProc;
1142       '+': fProcTable[I] := @PlusProc;
1143       '/': fProcTable[I] := @SlashProc;
1144       '&': fProcTable[I] := @AndSymbolProc;
1145       #34: fProcTable[I] := @StringProc;
1146       ':', '@':
1147         fProcTable[I] := @VariableProc;
1148       'A'..'Z', 'a'..'z', '_':
1149         fProcTable[I] := @IdentProc;
1150       '0'..'9':
1151         fProcTable[I] := @NumberProc;
1152       #1..#9, #11, #12, #14..#32:
1153         fProcTable[I] := @SpaceProc;
1154       '^', '%', '*', '!':
1155         fProcTable[I] := @SymbolAssignProc;
1156       '{', '}', '.', ',', ';', '?', '(', ')', '[', ']', '~':
1157         fProcTable[I] := @SymbolProc;
1158       else
1159         fProcTable[I] := @UnknownProc;
1160     end;
1161 end;
1162 
1163 constructor TSynSQLSyn.Create(AOwner: TComponent);
1164 begin
1165   inherited Create(AOwner);
1166   fKeywords := TSynHashEntryList.Create;
1167   fTableNames := TStringList.Create;
1168   TStringList(fTableNames).OnChange := @TableNamesChanged;
1169   fCommentAttri := TSynHighlighterAttributes.Create(@SYNS_AttrComment, SYNS_XML_AttrComment);
1170   fCommentAttri.Style := [fsItalic];
1171   AddAttribute(fCommentAttri);
1172   fDataTypeAttri := TSynHighlighterAttributes.Create(@SYNS_AttrDataType, SYNS_XML_AttrDataType);
1173   fDataTypeAttri.Style := [fsBold];
1174   AddAttribute(fDataTypeAttri);
1175 {begin}                                                                         // DJLP 2000-08-11
1176   fDefaultPackageAttri :=
1177     TSynHighlighterAttributes.Create(@SYNS_AttrDefaultPackage, SYNS_XML_AttrDefaultPackage);
1178   fDefaultPackageAttri.Style := [fsBold];
1179   AddAttribute(fDefaultPackageAttri);
1180 {end}                                                                           // DJLP 2000-08-11
1181   fExceptionAttri := TSynHighlighterAttributes.Create(@SYNS_AttrException, SYNS_XML_AttrException);
1182   fExceptionAttri.Style := [fsItalic];
1183   AddAttribute(fExceptionAttri);
SYNS_XML_AttrFunctionnull1184   fFunctionAttri := TSynHighlighterAttributes.Create(@SYNS_AttrFunction, SYNS_XML_AttrFunction);
1185   fFunctionAttri.Style := [fsBold];
1186   AddAttribute(fFunctionAttri);
1187   fIdentifierAttri := TSynHighlighterAttributes.Create(@SYNS_AttrIdentifier, SYNS_XML_AttrIdentifier);
1188   AddAttribute(fIdentifierAttri);
1189   fKeyAttri := TSynHighlighterAttributes.Create(@SYNS_AttrReservedWord, SYNS_XML_AttrReservedWord);
1190   fKeyAttri.Style := [fsBold];
1191   AddAttribute(fKeyAttri);
1192   fNumberAttri := TSynHighlighterAttributes.Create(@SYNS_AttrNumber, SYNS_XML_AttrNumber);
1193   AddAttribute(fNumberAttri);
1194 {begin}                                                                         // DJLP 2000-08-11
1195   fPLSQLAttri := TSynHighlighterAttributes.Create(@SYNS_AttrPLSQL, SYNS_XML_AttrPLSQL);
1196   fPLSQLAttri.Style := [fsBold];
1197   AddAttribute(fPLSQLAttri);
1198 {end}                                                                           // DJLP 2000-08-11
1199   fSpaceAttri := TSynHighlighterAttributes.Create(@SYNS_AttrSpace, SYNS_XML_AttrSpace);
1200   AddAttribute(fSpaceAttri);
1201 {begin}                                                                         // DJLP 2000-09-05
1202   fSQLPlusAttri:=TSynHighlighterAttributes.Create(@SYNS_AttrSQLPlus, SYNS_XML_AttrSQLPlus);
1203   fSQLPlusAttri.Style := [fsBold];
1204   AddAttribute(fSQLPlusAttri);
1205 {end}                                                                           // DJLP 2000-09-05
1206   fStringAttri := TSynHighlighterAttributes.Create(@SYNS_Attrstring, SYNS_XML_Attrstring);
1207   AddAttribute(fStringAttri);
1208   fSymbolAttri := TSynHighlighterAttributes.Create(@SYNS_AttrSymbol, SYNS_XML_AttrSymbol);
1209   AddAttribute(fSymbolAttri);
1210   fTableNameAttri := TSynHighlighterAttributes.Create(@SYNS_AttrTableName, SYNS_XML_AttrTableName);
1211   AddAttribute(fTableNameAttri);
1212   fVariableAttri := TSynHighlighterAttributes.Create(@SYNS_AttrVariable, SYNS_XML_AttrVariable);
1213   AddAttribute(fVariableAttri);
1214   SetAttributesOnChange(@DefHighlightChange);
1215   MakeMethodTables;
1216   fDefaultFilter := SYNS_FilterSQL;
1217   fRange := rsUnknown;
1218   fDialect := sqlStandard;
1219   SQLDialect := sqlSybase;
1220 end;
1221 
1222 destructor TSynSQLSyn.Destroy;
1223 begin
1224   fKeywords.Free;
1225   fTableNames.Free;
1226   inherited Destroy;
1227 end;
1228 
1229 procedure TSynSQLSyn.Assign(Source: TPersistent);
1230 begin
1231   inherited Assign(Source);
1232   if (Source is TSynSQLSyn) then
1233     SQLDialect := TSynSQLSyn(Source).SQLDialect;
1234 end;
1235 
1236 procedure TSynSQLSyn.SetLine(const NewValue: string; LineNumber: Integer);
1237 begin
1238   inherited;
1239   fLine := PChar(NewValue);
1240   Run := 0;
1241   fLineNumber := LineNumber;
1242   Next;
1243 end;
1244 
1245 procedure TSynSQLSyn.AndSymbolProc;
1246 begin
1247   fTokenID := tkSymbol;
1248   Inc(Run);
1249   if fLine[Run] in ['=', '&'] then Inc(Run);
1250 end;
1251 
1252 procedure TSynSQLSyn.AsciiCharProc;
1253 begin
1254   // Oracle SQL allows strings to go over multiple lines
1255   if fLine[Run] = #0 then
1256     NullProc
1257   else begin
1258     fTokenID := tkString;
1259     // else it's end of multiline string
1260     if SQLDialect <> sqlMySql then begin
1261       if (Run > 0) or (fRange <> rsString) or (fLine[Run] <> #39) then begin
1262         fRange := rsString;
1263         repeat
1264           Inc(Run);
1265         until fLine[Run] in [#0, #10, #13, #39];
1266       end;
1267       if fLine[Run] = #39 then begin
1268         Inc(Run);
1269         fRange := rsUnknown;
1270       end;
1271     end
1272     else begin
1273       if (Run > 0) or (fRange <> rsString) or ((fLine[Run] <> #39) and (fLine[Run-1] <> '\')) then begin
1274         fRange := rsString;
1275         repeat
1276           if (fLine[Run] <> '\') and (fLine[Run+1] = #39) then begin
1277             Inc(Run);
1278             break;
1279           end;
1280           Inc(Run);
1281         until fLine[Run] in [#0, #10, #13];
1282       end;
1283       if (fLine[Run] = #39) and not(fLine[Run-1] = '\') then begin
1284         Inc(Run);
1285         fRange := rsUnknown;
1286       end;
1287     end;
1288   end;
1289 end;
1290 
1291 procedure TSynSQLSyn.CRProc;
1292 begin
1293   fTokenID := tkSpace;
1294   Inc(Run);
1295   if fLine[Run] = #10 then Inc(Run);
1296 end;
1297 
1298 procedure TSynSQLSyn.EqualProc;
1299 begin
1300   fTokenID := tkSymbol;
1301   Inc(Run);
1302   if fLine[Run] in ['=', '>'] then Inc(Run);
1303 end;
1304 
1305 procedure TSynSQLSyn.GreaterProc;
1306 begin
1307   fTokenID := tkSymbol;
1308   Inc(Run);
1309   if fLine[Run] in ['=', '>'] then Inc(Run);
1310 end;
1311 
1312 procedure TSynSQLSyn.IdentProc;
1313 begin
1314   fTokenID := IdentKind((fLine + Run));
1315   inc(Run, fStringLen);
1316 {begin}                                                                         // DJLP 2000-08-11
1317   if fTokenID = tkComment then begin
1318     while not (fLine[Run] in [#0, #10, #13]) do
1319       Inc(Run);
1320   end else
1321 {end}                                                                           // DJLP 2000-08-11
1322     while fIdentifiersPtr^[fLine[Run]] do inc(Run);
1323 end;
1324 
1325 procedure TSynSQLSyn.LFProc;
1326 begin
1327   fTokenID := tkSpace;
1328   inc(Run);
1329 end;
1330 
1331 procedure TSynSQLSyn.LowerProc;
1332 begin
1333   fTokenID := tkSymbol;
1334   Inc(Run);
1335   case fLine[Run] of
1336     '=': Inc(Run);
1337     '<': begin
1338            Inc(Run);
1339            if fLine[Run] = '=' then Inc(Run);
1340          end;
1341   end;
1342 end;
1343 
1344 procedure TSynSQLSyn.MinusProc;
1345 begin
1346   Inc(Run);
1347   if fLine[Run] = '-' then begin
1348     fTokenID := tkComment;
1349     repeat
1350       Inc(Run);
1351     until fLine[Run] in [#0, #10, #13];
1352   end else
1353     fTokenID := tkSymbol;
1354 end;
1355 
1356 procedure TSynSQLSyn.NullProc;
1357 begin
1358   fTokenID := tkNull;
1359 end;
1360 
1361 procedure TSynSQLSyn.NumberProc;
1362 begin
1363   inc(Run);
1364   fTokenID := tkNumber;
1365   while FLine[Run] in ['0'..'9'] do inc(Run);
1366   if (FLine[Run]='.') and not(fLine[Run+1]='.')  then begin
1367     inc(Run);
1368     while FLine[Run] in ['0'..'9'] do inc(Run);
1369   end;
1370   if (FLine[Run]='e') or (fLine[Run]='E')  then begin
1371     inc(Run);
1372     if (FLine[Run]='+') or (fLine[Run]='-')  then inc(Run);
1373     while FLine[Run] in ['0'..'9'] do inc(Run);
1374   end;
1375 end;
1376 
1377 procedure TSynSQLSyn.OrSymbolProc;
1378 begin
1379   fTokenID := tkSymbol;
1380   Inc(Run);
1381   if fLine[Run] in ['=', '|'] then Inc(Run);
1382 end;
1383 
1384 procedure TSynSQLSyn.PlusProc;
1385 begin
1386   fTokenID := tkSymbol;
1387   Inc(Run);
1388   if fLine[Run] in ['=', '+'] then Inc(Run);
1389 end;
1390 
1391 procedure TSynSQLSyn.SlashProc;
1392 begin
1393   Inc(Run);
1394   case fLine[Run] of
1395     '*':
1396       begin
1397         fRange := rsComment;
1398         fTokenID := tkComment;
1399         repeat
1400           Inc(Run);
1401           if (fLine[Run] = '*') and (fLine[Run + 1] = '/') then begin
1402             fRange := rsUnknown;
1403             Inc(Run, 2);
1404             break;
1405           end;
1406         until fLine[Run] in [#0, #10, #13];
1407       end;
1408     '=':
1409       begin
1410         Inc(Run);
1411         fTokenID := tkSymbol;
1412       end;
1413     else
1414       fTokenID := tkSymbol;
1415   end;
1416 end;
1417 
1418 procedure TSynSQLSyn.SpaceProc;
1419 begin
1420   fTokenID := tkSpace;
1421   repeat
1422     Inc(Run);
1423   until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]);
1424 end;
1425 
1426 procedure TSynSQLSyn.StringProc;
1427 begin
1428   fTokenID := tkString;
1429   Inc(Run);
1430   while not (fLine[Run] in [#0, #10, #13]) do begin
1431     case fLine[Run] of
1432       '\': if fLine[Run + 1] = #34 then
1433              Inc(Run);
1434       #34: if fLine[Run + 1] <> #34 then
1435            begin
1436              Inc(Run);
1437              break;
1438            end;
1439     end;
1440     Inc(Run);
1441   end;
1442 end;
1443 
1444 procedure TSynSQLSyn.SymbolProc;
1445 begin
1446   Inc(Run);
1447   fTokenID := tkSymbol;
1448 end;
1449 
1450 procedure TSynSQLSyn.SymbolAssignProc;
1451 begin
1452   fTokenID := tkSymbol;
1453   Inc(Run);
1454   if fLine[Run] = '=' then Inc(Run);
1455 end;
1456 
1457 procedure TSynSQLSyn.VariableProc;
1458 var
1459   i: integer;
1460 begin
1461   // MS SQL 7 uses @@ to indicate system functions/variables
1462   if (SQLDialect = sqlMSSQL7) and (fLine[Run] = '@') and (fLine[Run + 1] = '@')
1463   then
1464     IdentProc
1465 {begin}                                                                         //JDR 2000-25-2000
1466   else if (SQLDialect in [sqlMySql, sqlOracle]) and (fLine[Run] = '@') then
1467     SymbolProc
1468 {end}                                                                           //JDR 2000-25-2000
1469   // Oracle uses the ':' character to indicate bind variables
1470 {begin}                                                                         //JJV 2000-11-16
1471   // Ingres II also uses the ':' character to indicate variables
1472   else
1473     if not (SQLDialect in [sqlOracle, sqlIngres]) and (fLine[Run] = ':') then
1474 {end}                                                                           //JJV 2000-11-16
1475     SymbolProc
1476   else begin
1477     fTokenID := tkVariable;
1478     i := Run;
1479     repeat
1480       Inc(i);
1481     until not (fIdentifiersPtr^[fLine[i]]);
1482     Run := i;
1483   end;
1484 end;
1485 
1486 procedure TSynSQLSyn.UnknownProc;
1487 begin
1488   if (SQLDialect = sqlMySql) and (fLine[Run] = '#') and (Run = 0) then          //DDH Changes from Tonci Grgin for MYSQL
1489   begin
1490     fTokenID := tkComment;
1491     fRange := rsComment;
1492   end else begin
1493     {$IFDEF SYN_MBCSSUPPORT}
1494     if FLine[Run] in LeadBytes then
1495       Inc(Run,2)
1496     else
1497     {$ENDIF}
1498     inc(Run);
1499     while (fLine[Run] in [#128..#191]) OR // continued utf8 subcode
1500      ((fLine[Run]<>#0) and (fProcTable[fLine[Run]] = @UnknownProc)) do inc(Run);
1501     fTokenID := tkUnknown;
1502   end;
1503 end;
1504 
1505 procedure TSynSQLSyn.AnsiCProc;
1506 begin
1507   case fLine[Run] of
1508      #0: NullProc;
1509     #10: LFProc;
1510     #13: CRProc;
1511     else begin
1512       fTokenID := tkComment;
1513       if (SQLDialect = sqlMySql) and (fLine[Run] = '#') then begin              //DDH Changes from Tonci Grgin for MYSQL
1514         repeat
1515           Inc(Run);
1516         until fLine[Run] in [#0, #10, #13];
1517         fRange := rsUnknown;
1518       end
1519       else begin
1520 
1521         repeat
1522           if (fLine[Run] = '*') and (fLine[Run + 1] = '/') then begin
1523             fRange := rsUnknown;
1524             Inc(Run, 2);
1525             break;
1526           end;
1527           Inc(Run);
1528         until fLine[Run] in [#0, #10, #13];
1529       end;
1530     end;
1531   end;
1532 end;
1533 
1534 {begin}                                                                         // DJLP 2000-08-09
IsKeywordnull1535 function TSynSQLSyn.IsKeyword(const AKeyword: string): boolean;
1536 var
1537   tk: TtkTokenKind;
1538 begin
1539   tk := IdentKind(PChar(AKeyword));
1540   Result := tk in [tkDatatype, tkException, tkFunction, tkKey, tkPLSQL,
1541     tkDefaultPackage];
1542 end;
1543 {end}                                                                           // DJLP 2000-08-09
1544 
1545 procedure TSynSQLSyn.Next;
1546 begin
1547   fTokenPos := Run;
1548   case fRange of
1549     rsComment:
1550       AnsiCProc;
1551     rsString:
1552       AsciiCharProc;
1553   else
1554     fProcTable[fLine[Run]]();
1555   end;
1556 end;
1557 
GetDefaultAttributenull1558 function TSynSQLSyn.GetDefaultAttribute(Index: integer):
1559   TSynHighlighterAttributes;
1560 begin
1561   case Index of
1562     SYN_ATTR_COMMENT: Result := fCommentAttri;
1563     SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri;
1564     SYN_ATTR_KEYWORD: Result := fKeyAttri;
1565     SYN_ATTR_STRING: Result := fStringAttri;
1566     SYN_ATTR_WHITESPACE: Result := fSpaceAttri;
1567     SYN_ATTR_SYMBOL: Result := fSymbolAttri;
1568     SYN_ATTR_NUMBER: Result := fNumberAttri;
1569     SYN_ATTR_VARIABLE: Result := fVariableAttri;
1570   else
1571     Result := nil;
1572   end;
1573 end;
1574 
GetEolnull1575 function TSynSQLSyn.GetEol: Boolean;
1576 begin
1577   Result := fTokenID = tkNull;
1578 end;
1579 
GetRangenull1580 function TSynSQLSyn.GetRange: Pointer;
1581 begin
1582   Result := Pointer(PtrInt(fRange));
1583 end;
1584 
GetTokennull1585 function TSynSQLSyn.GetToken: string;
1586 var
1587   Len: LongInt;
1588 begin
1589   Result := '';
1590   Len := Run - fTokenPos;
1591   Setstring(Result, (FLine + fTokenPos), Len);
1592 end;
1593 
1594 procedure TSynSQLSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer);
1595 begin
1596   TokenLength:=Run-fTokenPos;
1597   TokenStart:=FLine + fTokenPos;
1598 end;
1599 
GetTokenIDnull1600 function TSynSQLSyn.GetTokenID: TtkTokenKind;
1601 begin
1602   Result := fTokenId;
1603 end;
1604 
GetTokenAttributenull1605 function TSynSQLSyn.GetTokenAttribute: TSynHighlighterAttributes;
1606 begin
1607   case GetTokenID of
1608     tkComment: Result := fCommentAttri;
1609     tkDatatype: Result := fDataTypeAttri;
1610     tkDefaultPackage: Result := fDefaultPackageAttri;                           // DJLP 2000-08-11
1611     tkException: Result := fExceptionAttri;
1612     tkFunction: Result := fFunctionAttri;
1613     tkIdentifier: Result := fIdentifierAttri;
1614     tkKey: Result := fKeyAttri;
1615     tkNumber: Result := fNumberAttri;
1616     tkPLSQL: Result := fPLSQLAttri;                                             // DJLP 2000-08-11
1617     tkSpace: Result := fSpaceAttri;
1618     tkSQLPlus: Result := fSQLPlusAttri;                                         // DJLP 2000-08-11
1619     tkString: Result := fStringAttri;
1620     tkSymbol: Result := fSymbolAttri;
1621     tkTableName: Result := fTableNameAttri;
1622     tkVariable: Result := fVariableAttri;
1623     tkUnknown: Result := fIdentifierAttri;
1624   else
1625     Result := nil;
1626   end;
1627 end;
1628 
GetTokenKindnull1629 function TSynSQLSyn.GetTokenKind: integer;
1630 begin
1631   Result := Ord(fTokenId);
1632 end;
1633 
GetTokenPosnull1634 function TSynSQLSyn.GetTokenPos: Integer;
1635 begin
1636   Result := fTokenPos;
1637 end;
1638 
1639 procedure TSynSQLSyn.ResetRange;
1640 begin
1641   fRange := rsUnknown;
1642 end;
1643 
1644 procedure TSynSQLSyn.SetRange(Value: Pointer);
1645 begin
1646   fRange := TRangeState(PtrUInt(Value));
1647 end;
1648 
GetIdentCharsnull1649 function TSynSQLSyn.GetIdentChars: TSynIdentChars;
1650 begin
1651   Result := TSynValidStringChars;
1652   if (fDialect = sqlMSSQL7) or (fDialect = sqlMSSQL2K) then
1653     Include(Result, '@')
1654 {begin}                                                                         // DJLP 2000-08-11
1655   else if fDialect = sqlOracle then begin
1656     Include(Result, '#');
1657     Include(Result, '$');
1658   end;
1659 {end}                                                                           // DJLP 2000-08-11
1660 end;
1661 
1662 class function TSynSQLSyn.GetLanguageName: string;
1663 begin
1664   Result := SYNS_LangSQL;
1665 end;
1666 
1667 procedure TSynSQLSyn.DoAddKeyword(AKeyword: string; AKind: integer);
1668 var
1669   HashValue: integer;
1670 begin
1671   HashValue := KeyHash(PChar(AKeyword));
1672   fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind);
1673 end;
1674 
1675 procedure TSynSQLSyn.SetTableNames(const Value: TStrings);
1676 begin
1677   fTableNames.Assign(Value);
1678 end;
1679 
1680 procedure TSynSQLSyn.TableNamesChanged(Sender: TObject);
1681 begin
1682   InitializeKeywordLists;
1683 end;
1684 
1685 procedure TSynSQLSyn.PutTableNamesInKeywordList;
1686 var
1687   i: Integer;
1688   Entry: TSynHashEntry;
1689 begin
1690   for i := 0 to (fTableNames.Count - 1) do
1691   begin
1692     Entry := fKeywords[KeyHash(PChar(fTableNames[i]))];
1693     while Assigned(Entry) do
1694     begin
1695       if (UpperCase(Entry.Keyword) = Uppercase(fTableNames[i])) then
1696         Break;
1697       Entry := Entry.Next;
1698     end;
1699     if not Assigned(Entry) then
1700       DoAddKeyword(fTableNames[i], Ord(tkTableName));
1701   end;
1702 end;
1703 
1704 procedure TSynSQLSyn.InitializeKeywordLists;
1705 begin
1706   fKeywords.Clear;
1707   if (fDialect in [sqlMSSQL7, sqlMSSQL2K]) then
1708   begin
1709     fIdentifiersPtr := @IdentifiersMSSQL7;
1710     fmHashTablePtr := @mHashTableMSSQL7;
1711   end else begin
1712     fIdentifiersPtr := @Identifiers;
1713     fmHashTablePtr := @mHashTable;
1714   end;
1715 
1716   case fDialect of
1717     sqlPostgres:
1718       begin
1719         EnumerateKeywords(Ord(tkKey), PostgresKW, IdentChars, @DoAddKeyword);
1720         EnumerateKeywords(Ord(tkDatatype), PostgresTypes, IdentChars,
1721           @DoAddKeyword);
1722         EnumerateKeywords(Ord(tkFunction), PostgresFunctions, IdentChars,
1723           @DoAddKeyword);
1724         EnumerateKeywords(Ord(tkException), PostgresExceptions, IdentChars,
1725           @DoAddKeyword);
1726       end;
1727     sqlSqlite:
1728       begin
1729         EnumerateKeywords(Ord(tkDatatype), SQLiteTypes, IdentChars,
1730           @DoAddKeyword);
1731         EnumerateKeywords(Ord(tkFunction), SQLiteFunctions, IdentChars,
1732           @DoAddKeyword);
1733         EnumerateKeywords(Ord(tkKey), SQLiteKW, IdentChars, @DoAddKeyword);
1734       end;
1735     sqlIngres:
1736       begin
1737         EnumerateKeywords(Ord(tkDatatype), IngresTypes, IdentChars,
1738           @DoAddKeyword);
1739         EnumerateKeywords(Ord(tkKey), IngresKW, IdentChars, @DoAddKeyword);
1740         EnumerateKeywords(Ord(tkFunction), IngresFunctions, IdentChars,
1741           @DoAddKeyword);
1742       end;
1743     sqlInterbase6:
1744       begin
1745         EnumerateKeywords(Ord(tkDatatype), Interbase6Types, IdentChars,
1746           @DoAddKeyword);
1747         EnumerateKeywords(Ord(tkFunction), Interbase6Functions, IdentChars,
1748           @DoAddKeyword);
1749         EnumerateKeywords(Ord(tkKey), Interbase6KW, IdentChars, @DoAddKeyword);
1750       end;
1751     sqlMSSQL7:
1752       begin
1753         EnumerateKeywords(Ord(tkKey), MSSQL7KW, IdentChars, @DoAddKeyword);
1754         EnumerateKeywords(Ord(tkDatatype), MSSQL7Types, IdentChars,
1755           @DoAddKeyword);
1756         EnumerateKeywords(Ord(tkFunction), MSSQL7Functions, IdentChars,
1757           @DoAddKeyword);
1758       end;
1759     sqlMSSQL2K:
1760       begin
1761         EnumerateKeywords(ord(tkKey), MSSQL2000KW, IdentChars, @DoAddKeyword);
1762         EnumerateKeywords(ord(tkDataType), MSSQL2000Types, IdentChars, @DoAddKeyword);
1763         EnumerateKeywords(ord(tkFunction), MSSQL2000Functions, IdentChars, @DoAddKeyword);
1764       end;
1765     sqlMySql:
1766       begin
1767         EnumerateKeywords(Ord(tkKey), MySqlKW, IdentChars, @DoAddKeyword);
1768         EnumerateKeywords(Ord(tkDatatype), MySqlTypes, IdentChars,
1769           @DoAddKeyword);
1770         EnumerateKeywords(Ord(tkFunction), MySqlFunctions, IdentChars,
1771           @DoAddKeyword);
1772       end;
1773     sqlOracle:
1774       begin
1775         EnumerateKeywords(Ord(tkKey), OracleKW, IdentChars, @DoAddKeyword);
1776         EnumerateKeywords(Ord(tkDatatype), OracleTypes, IdentChars,
1777           @DoAddKeyword);
1778         EnumerateKeywords(Ord(tkException), OracleExceptions, IdentChars,
1779           @DoAddKeyword);
1780         EnumerateKeywords(Ord(tkFunction), OracleFunctions, IdentChars,
1781           @DoAddKeyword);
1782         EnumerateKeywords(Ord(tkComment), OracleCommentKW, IdentChars,
1783           @DoAddKeyword);
1784         EnumerateKeywords(Ord(tkDefaultPackage), OracleDefaultPackages,
1785           IdentChars, @DoAddKeyword);
1786         EnumerateKeywords(Ord(tkPLSQL), OraclePLSQLKW, IdentChars,
1787           @DoAddKeyword);
1788         EnumerateKeywords(Ord(tkSQLPlus), OracleSQLPlusCommands, IdentChars,
1789           @DoAddKeyword);
1790       end;
1791     sqlStandard:
1792       EnumerateKeywords(Ord(tkKey), StandardKW, IdentChars + ['-'], @DoAddKeyword);
1793     sqlSybase:
1794       EnumerateKeywords(Ord(tkKey), SybaseKW, IdentChars, @DoAddKeyword);
1795   end;
1796   PutTableNamesInKeywordList;
1797   DefHighlightChange(Self);
1798 end;
1799 
1800 procedure TSynSQLSyn.SetDialect(Value: TSQLDialect);
1801 begin
1802   if (Value <> fDialect) then
1803   begin
1804     fDialect := Value;
1805     InitializeKeywordLists;
1806   end;
1807 end;
1808 
GetSampleSourcenull1809 function TSynSQLSyn.GetSampleSource: String;
1810 begin
1811   Result:= '';
1812   case fDialect of
1813     sqlPostgres:
1814       Result := '-- PostgreSQL SQL sample source'#13#10 +
1815         'SELECT datname'#13#10 +
1816         'FROM pg_database'#13#10 +
1817         'WHERE datname = ''postgres'';';
1818     sqlStandard:
1819       Result := '-- ansi sql sample source'#13#10 +
1820         'select name , region'#13#10 +
1821         'from cia'#13#10 +
1822         'where area < 2000'#13#10 +
1823         'and gdp > 5000000000';
1824     sqlInterbase6:
1825       Result := '/* Interbase sample source */'#13#10 +
1826         'SET TERM !! ;'#13#10 +
1827         #13#10 +
1828         'CREATE PROCEDURE HelloWorld(P_MSG VARCHAR(80)) AS'#13#10 +
1829         'BEGIN'#13#10 +
1830         '  EXECUTE PROCEDURE WRITELN(:P_MSG);'#13#10 +
1831         'END !!'#13#10 +
1832         #13#10 +
1833         'SET TERM ; !!';
1834     sqlMySQL:
1835       Result := '/* MySQL sample source*/'#13#10 +
1836         'SET @variable= { 1 }'#13#10 +
1837         #13#10 +
1838         'CREATE TABLE sample ('#13#10 +
1839         '        id INT NOT NULL,'#13#10 +
1840         '        first_name CHAR(30) NOT NULL,'#13#10 +
1841         '        PRIMARY KEY (id),'#13#10 +
1842         '        INDEX name (first_name));'#13#10 +
1843         #13#10 +
1844         'SELECT DATE_ADD("1997-12-31 23:59:59",'#13#10 +
1845         '        INTERVAL 1 SECOND);'#13#10 +
1846         #13#10 +
1847         '# End of sample';
1848     sqlOracle:
1849       Result := 'PROMPT Oracle sample source'#13#10 +
1850         'declare'#13#10 +
1851         '  x varchar2(2000);'#13#10 +
1852         'begin   -- Show some text here'#13#10 +
1853         '  select to_char(count(*)) into x'#13#10 +
1854         '  from tab;'#13#10 +
1855         #13#10 +
1856         '  dbms_output.put_line(''Hello World: '' || x);'#13#10 +
1857         'exception'#13#10 +
1858         '  when others then'#13#10 +
1859         '    null;'#13#10 +
1860         'end;';
1861     sqlSybase:
1862       Result := '/* SyBase example source */'#13#10 +
1863         'declare @Integer        int'#13#10 +
1864         #13#10 +
1865         '/* Good for positive numbers only. */'#13#10 +
1866         'select @Integer = 1000'#13#10 +
1867         #13#10 +
1868         'select "Positives Only" ='#13#10 +
1869         '  right(replicate("0",12) + '#13#10 +
1870         '    convert(varchar, @Integer),12)'#13#10 +
1871         #13#10 +
1872         '/* Good for positive and negative numbers. */'#13#10 +
1873         'select @Integer = -1000'#13#10 +
1874         #13#10 +
1875         'select "Both Signs" ='#13#10 +
1876         '  substring( "- +", (sign(@Integer) + 2), 1) +'#13#10 +
1877         '  right(replicate("0",12) + '#13#10 +
1878         '    convert(varchar, abs(@Integer)),12)'#13#10 +
1879         #13#10 +
1880         'select @Integer = 1000'#13#10 +
1881         #13#10 +
1882         'select "Both Signs" ='#13#10 +
1883         '  substring( "- +", (sign(@Integer) + 2), 1) +'#13#10 +
1884         '  right(replicate("0",12) + '#13#10 +
1885         '    convert(varchar, abs(@Integer)),12)'#13#10 +
1886         #13#10 +
1887         'go';
1888     sqlIngres:
1889       Result := '/* Ingres example source */'#13#10 +
1890         'DELETE'#13#10 +
1891         'FROM t1'#13#10 +
1892         'WHERE EXISTS'#13#10 +
1893         '(SELECT t2.column1, t2.column2'#13#10 +
1894         'FROM t2'#13#10 +
1895         'WHERE t1.column1 = t2.column1 and'#13#10 +
1896         't1.column2 = t2.column2)';
1897     sqlMSSQL7:
1898       Result := '/* SQL Server 7 example source */'#13#10 +
1899         'SET QUOTED_IDENTIFIER OFF'#13#10 +
1900         'GO'#13#10 +
1901         'SET ANSI_NULLS OFF'#13#10 +
1902         'GO'#13#10 +
1903         #13#10 +
1904         '/* Object:  Stored Procedure dbo.sp_PPQInsertOrder */'#13#10 +
1905         'CREATE PROCEDURE sp_PPQInsertOrder'#13#10 +
1906         '  @Name    varchar(25),'#13#10 +
1907         '  @Address varchar(255),'#13#10 +
1908         '  @ZipCode varchar(15)'#13#10 +
1909         'As'#13#10 +
1910         '  INSERT INTO PPQOrders(Name, Address, ZipCode, OrderDate)'#13#10 +
1911         '  VALUES (@Name, @Address, @ZipCode, GetDate())'#13#10 +
1912         #13#10 +
1913         '  SELECT SCOPE_IDENTITY()'#13#10 +
1914         'GO';
1915     sqlMSSQL2K:
1916       Result := '/* SQL Server2000 example source */'#13#10 +
1917         'SET QUOTED_IDENTIFIER OFF'#13#10 +
1918         'GO'#13#10 +
1919         'SET ANSI_NULLS OFF'#13#10 +
1920         'GO'#13#10 +
1921         #13#10 +
1922         '/* Object:  Stored Procedure dbo.sp_PPQInsertOrder */'#13#10 +
1923         'CREATE PROCEDURE sp_PPQInsertOrder'#13#10 +
1924         '  @Name    varchar(25),'#13#10 +
1925         '  @Address varchar(255),'#13#10 +
1926         '  @ZipCode varchar(15)'#13#10 +
1927         'As'#13#10 +
1928         '  INSERT INTO PPQOrders(Name, Address, ZipCode, OrderDate)'#13#10 +
1929         '  VALUES (@Name, @Address, @ZipCode, GetDate())'#13#10 +
1930         #13#10 +
1931         '  SELECT SCOPE_IDENTITY()'#13#10 +
1932         'GO';
1933   end;
1934 end;
1935 
1936 initialization
1937   MakeIdentTable;
1938   RegisterPlaceableHighlighter(TSynSQLSyn);
1939 
1940 end.
1941