Friday, April 4, 2014

Using Temp Table

1. Create temp table with property In Memory or TempDB

2. public void init()
{
    HRMAbsenceTable  hrmAbsenceTable;
    HRMAbsenceTrans hrmAbsenceTrans;
    A_AbsenceBalances _a_AbsenceBalances; //temp table (In Memory)

     super();

    while select sum(Hours),PostedDate,TransDate,
                    HRMAbsenceCodeId,                  
                    hrmAbsenceCodeGroupId
        from hrmAbsenceTrans
        group by PostedDate,hrmAbsenceTrans.TransDate,
                    HRMAbsenceCodeId,                  
                    hrmAbsenceCodeGroupId
        join hrmAbsenceTable      
        where hrmAbsenceTable.hrmAbsenceTableId==hrmAbsenceTrans.hrmAbsenceTableId
    {
        _a_AbsenceBalances.Approve=HcmWorker::find(HRMAbsenceTable::find(hrmAbsenceTrans.hrmAbsenceTableId).Worker_ApprovedBy).name();
        _a_AbsenceBalances.status=hrmAbsenceTable.status;
        _a_AbsenceBalances.PostedDate=hrmAbsenceTrans.PostedDate;
        _a_AbsenceBalances.transDate=hrmAbsenceTrans.transDate;
        _a_AbsenceBalances.TransferredDate=hrmAbsenceTrans.TransferredDate;
        _a_AbsenceBalances.TransferToPay=hrmAbsenceTrans.TransferToPay;
        _a_AbsenceBalances.transText=hrmAbsenceTrans.transText;
        _a_AbsenceBalances.hrmAbsenceCodeGroupId=hrmAbsenceTrans.hrmAbsenceCodeGroupId;
        _a_AbsenceBalances.hrmAbsenceCodeId=hrmAbsenceTrans.hrmAbsenceCodeId;
        _a_AbsenceBalances.hrmAbsenceTableId=hrmAbsenceTrans.hrmAbsenceTableId;
        _a_AbsenceBalances.IsTransToPay=hrmAbsenceTrans.IsTransToPay;
        _a_AbsenceBalances.Name=hrmAbsenceTrans.Name;
        _a_AbsenceBalances.hours=hrmAbsenceTrans.hours;
        _a_AbsenceBalances.PayType=hrmAbsenceTrans.PayType;
        _a_AbsenceBalances.Worker=hrmAbsenceTable.worker;
        _a_AbsenceBalances.doInsert();
    }
    A_AbsenceBalances.setTmp();
    A_AbsenceBalances.setTmpData(_a_AbsenceBalances);
    A_AbsenceBalances_ds.executeQuery();
}


No comments:

Post a Comment