If you have seen our DW/A WebCast Series, I have placed the script that was used to create the DiscountsApplied DW/A Class. Enjoy!
'Create an ADO connection object. Dim cnnConnection Set cnnConnection = CreateObject("ADODB.Connection")
'Create an ADO command object. Dim cmdCommand Set cmdCommand = CreateObject("ADODB.Command")
'Create an ADO record object. Dim recNew Set recNew = CreateObject("ADODB.Record")
'Open a connection (bind) to the provider.'Modify the values for Catalog, Database, User, and Password to match your'resources. cnnConnection.Open "URL=mscop://InProcConnect/Server=localhost:" & _ "Catalog=DWSchema:Database=StarterSite_datawarehouse:Trusted_Connection=Yes:" & _ "FastLoad=True"
'Set the connection in the command object. Set cmdCommand.ActiveConnection = cnnConnection
'Turn on "Schema Change" mode.'SchemaMode can be set to On, True, or 1 to turn the' schema change mode on. cmdCommand.CommandText = "SchemaMode=1" cmdCommand.Execute
'Create a new class in the Class Definition table. recNew.Open "Class/DiscountsApplied", cnnConnection, _ adModeWrite, adCreateOverwrite
'Set the attributes. recNew("ClassDefName") = "DiscountsApplied"'Always set SourceDefName to test_Source for new classes. recNew("SourceDefName") = "test_Source" recNew("Description") = "Discount Applied." recNew("GenerateTableDef") = 1 recNew("GeneratePartitionDef") = 1
'Create your own key. recNew("GenerateKeyDef") = 0
recNew("GenerateIdentity") = 1
'Save the new row. recNew("__Commit") = 1 recNew.Fields.Update recNew.Close
'Create an instance in the Member Definition table for the first member. recNew.Open "Member/DiscountsApplied/OrderGroupId", cnnConnection, _ adModeWrite, adCreateOverwrite
'Set the attributes. recNew("ClassDefName") = DiscountsApplied recNew("TypeName") = "UUID" recNew("Description") = "Identifier for an Order Group." recNew("IsPrimaryKey") = 0 recNew("DefaultValueAsStr") = "{00000000-0000-0000-0000-000000000000}" recNew("MemberDefName") = "OrderGroupId" recNew("GenerateColumnDef") = 1
'Create an instance in the Member Definition table for the first member. recNew.Open "Member/DiscountsApplied/LineItemId", cnnConnection, _ adModeWrite, adCreateOverwrite
'Set the attributes. recNew("ClassDefName") = DiscountsApplied recNew("TypeName") = "UUID" recNew("Description") = "Identifier for an Line Item." recNew("IsPrimaryKey") = 0 recNew("DefaultValueAsStr") = "{00000000-0000-0000-0000-000000000000}" recNew("MemberDefName") = "LineItemId" recNew("GenerateColumnDef") = 1
'Create an instance in the Class Key Definition table. recNew.Open "Key/DiscountsAppliedKey", cnnConnection, _ adModeWrite, adCreateOverwrite
'Set the attributes. recNew("ClassDefName") = "DiscountsApplied" recNew("Description") = "Unique key for the DiscountsApplied class."
'Create an instance in the Key Member table for the first member. recNew.Open "KeyMember/DiscountsAppliedKey/ordergroup_id", _ cnnConnection, adModeWrite, adCreateOverwrite
'Set the attributes for the first key member. recnew("MemDefName") = "OrderGroupId" recNew("OrdinalPosInKey") = 0 recNew("Description") = "First member of DiscountsAppliedKey." recNew("KeyDefName") = DiscountsAppliedKey
'Create an instance in the Key Member table for the second member. recNew.Open "KeyMember/DiscountsAppliedKey/OrderForm_Id", _ cnnConnection, adModeWrite, adCreateOverwrite
'Set the attributes for the second key member. recnew("MemDefName") = "LineItemId" recNew("OrdinalPosInKey") = 1 recNew("Description") = "Second member of DiscountsAppliedKey." recNew("KeyDefName") = DiscountsAppliedKey
'Commit the changes to the Data Warehouse schema. cmdCommand.CommandText = "CommitSchema" cmdCommand.Execute
'Turn off "Schema Change" mode.'If SchemaMode is set to a value other than On, True, or 1' it is turned off. cmdCommand.CommandText = "SchemaMode=0" cmdCommand.Execute
'Close the connection. cnnConnection.Close
Hope this helps!
Alan