Skip to content

Instantly share code, notes, and snippets.

@coramuirgen
Last active July 5, 2016 09:10
Show Gist options
  • Save coramuirgen/d4f298c49292f168f78c21592eb8dcb4 to your computer and use it in GitHub Desktop.
Save coramuirgen/d4f298c49292f168f78c21592eb8dcb4 to your computer and use it in GitHub Desktop.
Records Input Parse
Public Function PrepareFromInput(inputrecords As QueryableRecords, inputhasheader As RecordsHeaderType, ParamArray paraminput() As Variant) As QueryableRecords
On Error GoTo ErrHandler
' Input data supported:
' scalar value(s)
' arrays (single/multi dimensional)
' tuples (2-index)
' assocs (value must be scalar)
' lists/collections/enumerables/iterables
' map objects like Scripting.Dictionary (key:column name)/(value: field value or column of field values)
' ado/dao recordsets
' ms access tables/queries (as tabledef/querydef)
' nested data 2 levels deep, i.e. an enumerable container of a supported type (containing finally scalars)
' To add columns only, add in this.Columns
Dim inputdata As Var
Set inputdata = Var.Create(CVar(paraminput))
If Not ImportDataSupported(inputdata) Then
Err.Raise UNIMPLEMENTED
End If
Set inputrecords = PrepareEmpty(DefaultStorageModeOf(inputdata))
Set inputrecords = Append(inputrecords, inputhasheader, inputdata)
Set PrepareFromInput = inputrecords
CleanExit:
Exit Function
ErrHandler:
'Application.Run "LogEvent", "error", "Records", "Create", , Erl(), Err.number, Err.Description
Resume CleanExit
Resume
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment