Home > Class Reference > %SYS namespace > %SQL.Util.Import
Private  Storage   



Parameters Properties Methods Queries Indices ForeignKeys Triggers
15 13


dialect directory echoMode eosDelimiter
errorPause extensions input log
logFileName logOption messageMode recurse
summarizeErrors unsupported unsupportedFileName

%AddToSaveSet %ClassIsLatestVersion %ClassName %ConstructClone
%DispatchClassMethod %DispatchGetModified %DispatchGetProperty %DispatchMethod
%DispatchSetModified %DispatchSetMultidimProperty %DispatchSetProperty %Extends
%GetParameter %IsA %IsModified %New
%NormalizeObject %ObjectModified %OriginalNamespace %PackageName
%RemoveFromSaveSet %SerializeObject %SetModified %ValidateObject
ConvertStatementDelimiter CreateRoutine CreateTrigger Import
ImportDirectory getFiles interactive parseBatch


• property dialect as %String;
The SQL dialect of the source statements
• property directory as %String(MAXLEN="");
The directory containing files to be imported
• property echoMode as %Integer;
If echoMode is true then the source statement and the result of executing it are displayed on the current device.
• property eosDelimiter as %String;
End of Statement delimiter. This is typically a semi-colon or 'GO'.
• property errorPause as %Integer [ InitialExpression = 5 ];
The number of seconds to pause after reporting an error.
• property extensions as %String [ MultiDimensional ];
• property input as %Stream.Object;
The input stream object.
• property log as %XSQL.Log;
The log object.
• property logFileName as %String(MAXLEN="");
• property logOption as %Integer;
logOption specifies the type of logging to perform. 0 - no logging 1 - log to a single file (always the case for importStream) 2 - log to separate files when importing a directory, each file loaded will produce a separate log file whose name is the same as the current input file with the extension of ".log" replacing the original extension. Unsupported statements are still written to a single file. If the log file name generated by replacing the input file name's extension with 'log' already exists then it will be appended.
• property messageMode as %Integer;
• property recurse as %Integer;
• property summarizeErrors as %Integer [ InitialExpression = 0 ];
• property unsupported as %XSQL.Log;
• property unsupportedFileName as %String(MAXLEN="");


• classmethod ConvertStatementDelimiter(pInput As %String(MAXLEN=""), pOutput As %String(MAXLEN=""), pEOS As %String = ";", pTranslateTable As %String(MAXLEN="")="") as %Status
This method converts the statement delimiter in a file containing SQL statements from the specified delimited into "GO". The "GO" delimiter is the only delimiter recognized by the TSQL parser in batch mode. Call this method, passing in the input file, the output file, the current statement delimiter and the translate table to use for the files. The converted statement output is saved to the output file. This method is not exact but it attempts to locate the end of statement by searching for the statement type and detecting embedded statement delimiters. Some CREATE PROCEDURE, CREATE FUNCTION, and CREATE TRIGGER statements can be incorrectly converted. It is the responsiblity of the user to verify the EOS conversion for all statements.
• classmethod CreateRoutine(pRoutineType As %String = "PROCEDURE", pClass As %Dictionary.ClassDefinition = "", pSchemaName As %Library.String(MAXLEN=128)="", pRoutineName As %Library.String(MAXLEN=250)="", pFormalSpec As %Library.String(MAXLEN=""), pReturnType As %Library.String(MAXLEN=""), pLanguage As %Library.String, ByRef pImplementation As %Library.String(MAXLEN=""), pDialect As %String = "") as %Library.Integer
CreateRoutine creates an SQL Invoked Routine in a class definition. SQL Invoked Routines (SIRs) are functions and procedures. A function accepts an arbitrary number of INPUT parameters and returns a single value. A procedure accepts an arbitrary number of INPUT, INPUT-OUTPUT, and OUTPUT values, may return a value and may return DYNAMIC result sets. An SIR is implemented in COS, TSQL, or ???. Called from %Compiler.TSQL.COS
• classmethod CreateTrigger(pTableName As %Library.String, pTriggerName As %Library.String, pEvent As %Library.String, pTime As %Library.String, order As %Library.String = "last", level As %Library.String = "", language As %Library.String = "", newtable As %Library.String(MAXLEN=128)="inserted", oldtable As %Library.String(MAXLEN=128)="deleted", ByRef code As %Library.String(MAXLEN=""))
• classmethod Import(pDialect As %String = "", pInputStream As %Stream.Object = "", pLog As %XSQL.Log = "", pErrorsLog As %XSQL.Log = "", pErrorPause As %Integer = 5, pMessageMode As %Integer = 0, pEchoMode As %Integer = 0, pCumulative As %Integer = 0, pStatementDelimiter As %Library.String = "GO")
pMessageMode - if true, status and progress messages are displayed on the current device. pEcho - if true, each statement loaded and the result of executing it will be displayed on the current device. pCumulative - internal argument. If true then error information and counts accumulate in a process-private global. pStatementDelimiter - end of statement delimiter, defaults to "GO".
• classmethod ImportDirectory(pDialect As %Library.String = "", pDirectory As %Library.String = "", pExtensions As %Library.String(MAXLEN="")="sql", pRecurse As %Boolean = 0, pLogOption As %Integer = 0, pLogFileName As %Library.String = "", pNoSupFileName As %Library.String = "", pStatementDelimiter As %Library.String = "GO", pMessageMode As %Boolean = 1, pEchoMode As %Boolean = 1, pErrorPause As %Integer = 5)
ImportDirectory will import all files with an extension that matches the list of extensions included in the pExtensions argument. pDialect - this is the SQL dialect. Default is IRIS. Other valid values are MSSQLSERVER, MSSQL, and Sybase. Other dialects are supported by %SYSTEM.SQL. pDirectory - the directory path containing files to be imported. pExtensions - a comma delimited list of file extensions to import. The default is "sql". pRecurse - if true, then the all subdirectories of pDirectory are also imported. pLogOption - if true, statements and execution results will be logged to the pLogFileName file. pLogFileName - name of the log file. pNoSupFileName - name of the file to log unsupported statements. pStatementDelimiter - end of statement delimiter, defaults to "GO". pMessageMode - if true then all messages reported by executing imported statements will be displayed on the current device. pEchoMode - if true, all statement source is displayed on the current device. pErrorPause - the number of seconds to pause when an error is reported. The default is five seconds.
• classmethod getFiles(pDirectory, ByRef pExtension, pTempNode, pRecurse)
internal method to retrieve all of the files currently in the directory and, if pRecurse is true, all subdirectories. Only files whose extension matches an extension in pExtension are retrieved.
• classmethod interactive(pDialect As %String = "", pInputFileName As %String(MAXLEN="")="", ByRef pMessageMode As %Integer, ByRef pEchoMode As %Integer)
This is the dialog for importing a file containing SQL statements. It gathers the input file name, log files, and display options before calling the import() method.
• classmethod parseBatch(pInput As %Stream.Object, pOutput As %Stream.FileCharacter, pEOS As %String = ";")
Convert a batch delimited by some character into a batch delimited by GO on a single line.
• classmethod yesOrNo(pPrompt As %String(MAXLEN=""), pDefault As %String = "Y") as %Boolean