Copy the code below
REM -----------------------------------------------------------------------
REM
REM Name : del_asset.sql
REM Release : 10.4 or later
REM This script deletes all data for one asset in all the books.
REM To run from command line, do:
REM sqlplus fa/ @del_asset
REM and enter the asset number.
REM CAUTION :
REM 1) This is an IRREVERSIBLE procedure.
REM 2) If the asset has been posted to General Ledger, manual adjustments in
REM GL are needed to maintain data integrity.
REM 3) The audit trail for this asset will be PERMANENTLY lost. The reports
REM produced prior to running this script should not be used anymore.
REM 4) If the asset was created from Account Payables via Mass Additions, the
REM link between the asset and the invoice in AP will be LOST.
REM 5) You may do ROLLBACK if you feel that something was not done correctly.
REM
PROMPT CAUTION :
PROMPT 1) This is an IRREVERSIBLE procedure.
PROMPT 2) If the asset has been posted to General Ledger, manual adjustments in
PROMPT GL are needed to maintain data integrity.
PROMPT 3) The audit trail for this asset will be PERMANENTLY lost. The reports
PROMPT produced prior to running this script should not be used anymore.
PROMPT 4) If the asset was created from Account Payables via Mass Additions,
the
PROMPT link between the asset and the invoice in AP will be LOST.
PROMPT 5) You may do ROLLBACK if you feel that something was not done
correctly.
PROMPT You may also use Control-C anytime to interrupt the script.
SELECT ASSET_ID FROM FA_ADDITIONS_B
WHERE ASSET_NUMBER = '&ASSET_NUMBER';
DELETE FROM FA_INVOICE_TRANSACTIONS
WHERE INVOICE_TRANSACTION_ID IN ( SELECT INVOICE_TRANSACTION_ID_IN
FROM FA_ASSET_INVOICES
WHERE ASSET_ID = &&ASSET_ID )
OR INVOICE_TRANSACTION_ID IN ( SELECT INVOICE_TRANSACTION_ID_OUT
FROM FA_ASSET_INVOICES
WHERE ASSET_ID = &&ASSET_ID );
DELETE FROM FA_TRANSFER_DETAILS
WHERE DISTRIBUTION_ID IN ( SELECT FDH.DISTRIBUTION_ID
FROM FA_DISTRIBUTION_HISTORY FDH
WHERE ASSET_ID = &&ASSET_ID );
DELETE FROM FA_ACE_BOOKS WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_ADDITIONS_B WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_ADJUSTMENTS WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_ASSET_HISTORY WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_ASSET_INVOICES WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_BALANCES_REPORT WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_BOOKS WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_CAPITAL_BUDGET WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_DEFERRED_DEPRN WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_DEPRN_DETAIL WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_DEPRN_SUMMARY WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_DISTRIBUTION_HISTORY WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_MASS_REVALUATION_RULES WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_PERIODIC_PRODUCTION WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_RESERVE_LEDGER WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_RETIREMENTS WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_TRANSACTION_HEADERS WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_BOOKS_SUMMARY WHERE ASSET_ID = &&ASSET_ID;
-- mc
DELETE FROM FA_MC_ADJUSTMENTS WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_MC_ASSET_INVOICES WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_MC_BOOKS WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_MC_DEPRN_DETAIL WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_MC_DEPRN_SUMMARY WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_MC_BOOKS_SUMMARY WHERE ASSET_ID = &&ASSET_ID;
DELETE FROM FA_MC_RETIREMENTS WHERE ASSET_ID = &&ASSET_ID;
undef asset_id