SQL Export Data with %SQL.ExportMgr
Hi Everyone,
I am trying the Export and Import application as per this link referred here: ExImData
I have the following sample class I am trying to import:
{ Property Name As %String; Storage Default
{
<Data name="PersonBackupDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Name</Value>
</Value>
</Data>
<DataLocation>^Persistent.PersonBackupD</DataLocation>
<DefaultData>PersonBackupDefaultData</DefaultData>
<IdLocation>^Persistent.PersonBackupD</IdLocation>
<IndexLocation>^Persistent.PersonBackupI</IndexLocation>
<StreamLocation>^Persistent.PersonBackupS</StreamLocation>
<Type>%Library.CacheStorage</Type>
} }
And the below is the SQL Representation:
When I try to Export this data using the %SQL.ExportMgr with the following code (as per example in the referred link)
setupExportImport(Wizard,SchemaName,TableName)
If Wizard = "Export" {
set mgr = ##class(%SQL.Export.Mgr).%New()
}
Else { Set mgr = ##class(%SQL.Import.Mgr).%New() }
Set mobj = ##class(%SQL.Manager.API).%New()
Set ok = mobj.CheckIdentifier(.SchemaName)
Set ok = mobj.CheckIdentifier(.TableName)
Set classname = mobj.FindClassName(SchemaName_"."_TableName)
Set mgr.FileName = "c:\intersystems\cachepro\mgr\user\data.txt"
Set mgr.TableName = SchemaName_"."_TableName
Set mgr.ClassName = classname
Set mgr.Delimiter = $c(9) // tab
Set mgr.StringQuote = "" // double quotes
Set mgr.DateFormat = 1 // MM/DD/{YY}YY
Set mgr.TimeFormat = 1 // hh:mm:ss
Set mgr.TimeStampFormat = 1 // ODBC format (Import only)
Set mgr.NoCheck = 1 // disable validation (Import only)
Set mgr.HasHeaders = 1 // import file contains column headers
Do mgr.ColumnNames.Insert("Name") // insert a column name
Do mgr.ColumnTypes.Insert("String") // insert a column datatype
if (Wizard="Export") do Export
quit
Export()
Set result = mgr.GenerateExportRoutine()
If result '= 1 Write !,"Error generating export routine: ",result Quit
Set sta = mgr.OpenExport()
If $$$ISERR(sta) {
Set ErrMsg = "Unable to open export file"
} Else {
Set sta = mgr.GetExportSize(.size)
If size = 0 {
} Else {
Set tSC = $$$OK
Do {
Set tSC = mgr.ExportRows(.rows,.done)
Set total = total + rows
If $$$ISERR(tSC) Quit
} While done = 0
If $$$ISOK(tSC) {
Set tmsg = "Completed at "_$ZDATETIME($HOROLOG)
} Else {
Set tmsg ="Error occurred during export."
}
Set statusmsg = "Exported: "_total_" rows"
Write !,tmsg,!,statusmsg
}
Do mgr.CloseExport()
}
Do mgr.DeleteExportRoutine()
Quit
I keep getting the following error:
I have no idea what is causing this error as this code is generated in the function:
Any input is highly appreciated.