Hi. I have a script running Application Engine. It should be updating the data in a created cube that exists in the staging area. The script however is overwriting the data in the cube. Can you assist me in updating the script so that it updates the cube and not overwrite the data with the new data. I cannot load the full data set as I get an error " An error has occurred: Remote connection to Application Engine Service has been closed and cannot be used for communication anymore" when I run the Application Engine script with the full data set (1.7 million records). Script is below
#define EngineVersion 5.0
#define RuntimeVersion 5.0
bool FCIB_StagingToGLTOTCube()
@Description: "Import Staging Fact data into GLTOT_Ext cube";
@Category: "FCIB_dEPM_DataIntegration";
@Returns: "True";
{
//TST
//01. Add your BI# code here.
string server = "FSM";
string cube = "GLTOT_Ext";
//02. Connect to SQL Server
SQLConnection Staging = SQLCreateNamedConnection("Staging");
//NotifyInformation("SQL Connection Established");
//03. Query SQL database and retrieve all records from the TB Table
SQLData resultData = SQLExecuteQuery(Staging,"SELECT * FROM GLTOT_Fact;"); //Only use SELECT * if you want all columns
//NotifyInformation("Result Dataset created");
//04. Connect to OLAP Fincon DataBase
OLAPConnection connection = OLAPCreatePooledNamedConnection(server);
OLAPCellWriteBuffer buffer = OLAPCreateCellWriteBuffer(connection, true, 5000);
//NotifyInformation("OLAP Connection established");
//05. Create Target Data area
OLAPDataArea GLTOTDataArea = OLAPCreateDataArea(connection, cube,
OlapDataAreaIncludeB |
OlapDataAreaSuppressNull, OlapDataAreaOperatorNotEqual,
0.0, OlapDataAreaOperatorNone, 0.0,
OlapDataAreaBCells,
OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells,
OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells,
OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells,
OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells,
OlapDataAreaBCells,OlapDataAreaBCells,OlapDataAreaBCells);
//NotifyInformation("Data area GLTOTDataArea created");
//06. Delete Target Data area
//OLAPDeleteDataArea(GLTOTDataArea);
//07. Loop through SQL resultSet
int count=0;
int Rowcount=0;
StringList rows = CreateStringList();
foreach (SQLDataRow row in resultData)
{
string GLTOT_AccountingEntity = SQLDataRowGetString(row, "GLTOT_AccountingEntity");
string GLTOT_AccountingUnit = SQLDataRowGetString(row, "GLTOT_AccountingUnit");
string GLTOT_CalendarPeriod = SQLDataRowGetString(row, "GLTOT_CalendarPeriod");
string GLTOT_ChartAccount = SQLDataRowGetString(row, "GLTOT_ChartAccount");
string GLTOT_Currency = SQLDataRowGetString(row, "GLTOT_Currency");
string GLTOT_FinanceDimension1 = SQLDataRowGetString(row, "GLTOT_FinanceDimension1");
string GLTOT_FinanceDimension2 = SQLDataRowGetString(row, "GLTOT_FinanceDimension2");
string GLTOT_FinanceDimension3 = SQLDataRowGetString(row, "GLTOT_FinanceDimension3");
string GLTOT_FinanceDimension4 = SQLDataRowGetString(row, "GLTOT_FinanceDimension4");
string GLTOT_FinanceDimension5 = SQLDataRowGetString(row, "GLTOT_FinanceDimension5");
string GLTOT_FinanceDimension6 = SQLDataRowGetString(row, "GLTOT_FinanceDimension6");
string GLTOT_FinanceDimension7 = SQLDataRowGetString(row, "GLTOT_FinanceDimension7");
string GLTOT_FinanceDimension8 = SQLDataRowGetString(row, "GLTOT_FinanceDimension8");
string GLTOT_FinanceDimension9 = SQLDataRowGetString(row, "GLTOT_FinanceDimension9");
string GLTOT_FinanceDimension10 = SQLDataRowGetString(row, "GLTOT_FinanceDimension10");
string GLTOT_Ledger = SQLDataRowGetString(row, "GLTOT_Ledger");
string GLTOT_Measures = SQLDataRowGetString(row, "GLTOT_Measures");
string GLTOT_Project = SQLDataRowGetString(row, "GLTOT_Project");
string GLTOT_Scenario = SQLDataRowGetString(row, "GLTOT_Scenario");
string GLTOT_System = SQLDataRowGetString(row, "GLTOT_System");
double value = SQLDataRowGetDouble(row, "ValueColumn");
count = count + 1;
//WriteLine("Account: " + account + " Value: " + value);
OLAPCellWriteBufferWriteNumber(buffer, cube, value, GLTOT_AccountingEntity, GLTOT_AccountingUnit, GLTOT_CalendarPeriod,
GLTOT_ChartAccount, GLTOT_Currency, GLTOT_FinanceDimension1, GLTOT_FinanceDimension2,
GLTOT_FinanceDimension3, GLTOT_FinanceDimension4, GLTOT_FinanceDimension5, GLTOT_FinanceDimension6,
GLTOT_FinanceDimension7, GLTOT_FinanceDimension8, GLTOT_FinanceDimension9, GLTOT_FinanceDimension10,
GLTOT_Ledger, GLTOT_Measures, GLTOT_Project, GLTOT_Scenario, GLTOT_System);
//Rowcount = count + Rowcount;
//NotifyInformation("Records Synced : "+ Rowcount);
//OLAPCommitCellWriteBuffer(buffer);
}
OLAPCommitCellWriteBuffer(buffer);
NotifyInformation("Count: "+ count);
OLAPDisconnectPooledConnection(connection);
return true;
}