BvCF
MIS
- Nov 11, 2006
- 92
Trying to determine the most efficient method to import data from Oracle 8.1.7 database and append to a local Microsoft Access (Access 2000) table on a daily basis.
Have the sql script below;
SELECT DISTINCT
AL1.ACCOUNT_ID as AcctOrig,
AL1.ACCOUNT_ID as AcctCurrent,
AL7.ENCOUNTER_NO as AcctNo,
AL2.CUSTOMER_TYPE as CustType,
AL6.LAST_NAME as LastName,
AL6.FIRST_NAME as FirstName,
AL2.EXPECTED_PAYMENT - AL1.TOTAL_PAYMENTS as BalAfterInsPymts,
AL2.EXPECTED_PAYMENT - AL2.TOTAL_PAYMENTS as BalAfterAllPymts,
AL1.TOTAL_PAYMENTS / AL2.EXPECTED_PAYMENT as OrigRatio ,
AL2.TOTAL_PAYMENTS - AL1.TOTAL_PAYMENTS as OthPymts,
AL2.TOTAL_CHARGES - (AL2.NONCOVERED_DC_CHARGES + AL2.NONCOVERED_CT_CHARGES)as CoveredCharges,
AL2.TOTAL_CHARGES - Sum (AL5.ADJUSTMENT_AMOUNT) as AllowOrig,
AL2.TOTAL_CHARGES - Sum ( AL5.ADJUSTMENT_AMOUNT) as AllowCurrent,
FROM
CV_OCXVW.ACCOUNT_PAYOR AL1,
CV_OCXVW.CUSTOMER_ENCOUNTER AL2,
CV_OCXVW.ACCOUNT_TRANSACTION_DETAILS AL5,
CV_OCXVW.CUSTOMER AL6,
CV_OCXVW.ACCOUNT_PAYMENT_DETAIL AL7
WHERE AL2.AcctNo = AL1.AcctNo
AND AL2.AcctNo = AL5.AcctNo
AND AL6.CUSTOMER_NO = AL2.CUSTOMER_NO
AND AL7.AcctNo = AL1.AcctNo
AND AL1.ACCOUNT_ID Not In ('D15','D16','D17')
AND AL2.EXPECTED_PAYMENT>0
AND AL5.TRANSACTION_CODE in ('86004','86020','86035','86036','86037')
AND AL1.RANK=1
AND AL7.TRANSACTION_CODE in ('47003','47008','47009','47010','47011','47012','47013')
AND AL7.PAYMENT_DATE IN (
SELECT AL14.PAYMENT_DATE
FROM CV_OCXVW.ACCOUNT_PAYMENT_DETAIL AL14
WHERE AL14.TRANSACTION_CODE in ('47003','47008','47009','47010','47011','47012',
'47013'))
AND trunc(AL7.DATE_INTERFACED) = trunc (sysdate) - 1
GROUP BY
AL1.ACCOUNT_ID,
AL1.ACCOUNT_ID,
AL7.AcctNo,
AL2.CustType,
AL6.LAST_NAME,
AL6.FIRST_NAME,
HAVING AL2.EXPECTED_PAYMENT - AL1.TOTAL_PAYMENTS >=5000
ORDER BY AL7.DATE_INTERFACED
Options include;
Sql Passthrough queries and use of temp table in Access
or ADO Recordsets
Linking to the Oracle tables is not an option due to the complexity of the SQL.
Currently, I have several passthrough queries and read where one can drag them to a new query and convert to an append query. I have tried this but have not been able to get it to work.
On a daily basis, importing no more than 100 records.
Based on the limited number of records, which of the above-mentioned options would be preferable? Also read about the use of functions to accomplish this.
Thanks for any insight.
Have the sql script below;
SELECT DISTINCT
AL1.ACCOUNT_ID as AcctOrig,
AL1.ACCOUNT_ID as AcctCurrent,
AL7.ENCOUNTER_NO as AcctNo,
AL2.CUSTOMER_TYPE as CustType,
AL6.LAST_NAME as LastName,
AL6.FIRST_NAME as FirstName,
AL2.EXPECTED_PAYMENT - AL1.TOTAL_PAYMENTS as BalAfterInsPymts,
AL2.EXPECTED_PAYMENT - AL2.TOTAL_PAYMENTS as BalAfterAllPymts,
AL1.TOTAL_PAYMENTS / AL2.EXPECTED_PAYMENT as OrigRatio ,
AL2.TOTAL_PAYMENTS - AL1.TOTAL_PAYMENTS as OthPymts,
AL2.TOTAL_CHARGES - (AL2.NONCOVERED_DC_CHARGES + AL2.NONCOVERED_CT_CHARGES)as CoveredCharges,
AL2.TOTAL_CHARGES - Sum (AL5.ADJUSTMENT_AMOUNT) as AllowOrig,
AL2.TOTAL_CHARGES - Sum ( AL5.ADJUSTMENT_AMOUNT) as AllowCurrent,
FROM
CV_OCXVW.ACCOUNT_PAYOR AL1,
CV_OCXVW.CUSTOMER_ENCOUNTER AL2,
CV_OCXVW.ACCOUNT_TRANSACTION_DETAILS AL5,
CV_OCXVW.CUSTOMER AL6,
CV_OCXVW.ACCOUNT_PAYMENT_DETAIL AL7
WHERE AL2.AcctNo = AL1.AcctNo
AND AL2.AcctNo = AL5.AcctNo
AND AL6.CUSTOMER_NO = AL2.CUSTOMER_NO
AND AL7.AcctNo = AL1.AcctNo
AND AL1.ACCOUNT_ID Not In ('D15','D16','D17')
AND AL2.EXPECTED_PAYMENT>0
AND AL5.TRANSACTION_CODE in ('86004','86020','86035','86036','86037')
AND AL1.RANK=1
AND AL7.TRANSACTION_CODE in ('47003','47008','47009','47010','47011','47012','47013')
AND AL7.PAYMENT_DATE IN (
SELECT AL14.PAYMENT_DATE
FROM CV_OCXVW.ACCOUNT_PAYMENT_DETAIL AL14
WHERE AL14.TRANSACTION_CODE in ('47003','47008','47009','47010','47011','47012',
'47013'))
AND trunc(AL7.DATE_INTERFACED) = trunc (sysdate) - 1
GROUP BY
AL1.ACCOUNT_ID,
AL1.ACCOUNT_ID,
AL7.AcctNo,
AL2.CustType,
AL6.LAST_NAME,
AL6.FIRST_NAME,
HAVING AL2.EXPECTED_PAYMENT - AL1.TOTAL_PAYMENTS >=5000
ORDER BY AL7.DATE_INTERFACED
Options include;
Sql Passthrough queries and use of temp table in Access
or ADO Recordsets
Linking to the Oracle tables is not an option due to the complexity of the SQL.
Currently, I have several passthrough queries and read where one can drag them to a new query and convert to an append query. I have tried this but have not been able to get it to work.
On a daily basis, importing no more than 100 records.
Based on the limited number of records, which of the above-mentioned options would be preferable? Also read about the use of functions to accomplish this.
Thanks for any insight.