Hi,
I recently started using Toad for automating some of the tasks I perform daily. Mine is a Toad for Data Analysts, v 2.6.1.568, on a Windows 7, 32 bit machine.
When I manually run the script, it works perfectly. However, when I try to automate the script, it always ends up with the error described in the Subject.
Since I am a beginner at this, I don’t understand at all what is going wrong, and what the error message means - how come a file which will be generated anew once some data is exported to it be in use already?
I appreciate any help.
The log file is as follows:
– 3/20/2015 12:49:01 AM: Script_1.log: Build started
– 3/20/2015 12:49:12 AM: Script_1.log: Warning: No Exception Handler. To send an Email when there is an error, change the value of Email on Error to true and enter
email values.
– 3/20/2015 12:49:12 AM: Script_1.log: Build Completed
– 3/20/2015 12:49:13 AM: Script_1.log: Connecting to DWRAC (AIMIA), AIMIA
– 3/20/2015 12:49:14 AM: Script_1.log: Connection successful.
– 3/20/2015 12:49:14 AM: Script_1.log: Begin Export
– 3/20/2015 12:49:15 AM: Script_1.log: SQL to execute:
–TRUNCATE TABLE lp_redeem_data_temp;
–
–INSERT INTO lp_redeem_data_temp (time_stamp, redemption_date, trans_ID, account_id, msisdn, package_id, redeem_type, item_category, item_sub_category,
points_denomination, rdm_type, face_value, package_description, corp_pkg_flag, pay_type_code)
–SELECT t1.*,
– t2.rdm_type,
– t3.face_value,
– t4.package_description,
– t4.corp_pkg_flag,
– t4.pay_type_code
–FROM
– (
– SELECT time_stamp,
– TO_CHAR(time_stamp, ‘YYYYMMDD’) redemption_date,
– trans_ID,
– account_id,
– msisdn,
– package_id,
– redeem_type,
– item_category,
– item_sub_category,
– (num_points) points_denomination
– FROM lp_redeem_trans@lpapp
– WHERE time_stamp >= TO_DATE(SYSDATE - 7) and time_stamp < TO_DATE(SYSDATE)
– AND status = 2
– AND item_refunded <> ‘Y’
– UNION ALL
– SELECT time_stamp,
– TO_CHAR(time_stamp, ‘YYYYMMDD’) redemption_date,
– trans_ID,
– account_id,
– msisdn,
– package_id,
– redeem_type,
– item_category,
– item_sub_category,
– (num_points) points_denomination
– FROM lp_redeem_trans_archive@lpapp
– WHERE time_stamp >= TO_DATE(SYSDATE - 7) and time_stamp < TO_DATE(SYSDATE)
– AND status = 2
– AND item_refunded <> ‘Y’
– ) t1
–LEFT JOIN rdmtyp_lookup t2
– ON t1.item_category = t2.item_category
– AND t1.item_sub_category = t2.item_sub_category
–LEFT JOIN nonmpay_prtnr_rdm_tbl t3
– ON t1.item_category = t3.partner
– AND t1.item_sub_category = t3.partner_name
– AND t1.points_denomination = t3.points
–LEFT JOIN mgate_package_info@emaprod t4
– ON t1.package_id = t4.package_id;
–COMMIT;
–
–INSERT INTO weeklyTables_log (generation_date, table_name, total_count, unique_msisdn)
–SELECT TO_DATE(SYSDATE) generation_date,
– ‘lp_redeem_data_temp’ table_name,
– COUNT(*) total_count,
– COUNT(DISTINCT msisdn) unique_msisdn
–FROM lp_redeem_data_temp;
–COMMIT;
–
–TRUNCATE TABLE mpay_redeem_data_temp;
–
–INSERT INTO mpay_redeem_data_temp (time_stamp, redemption_date, trans_ID, account_id, msisdn, package_id, redeem_type, item_category, item_sub_category,
points_denomination, rdm_type, face_value, package_description, corp_pkg_flag, pay_type_code)
–SELECT t1.time_stamp,
– t1.redemption_date,
– t1.trans_ID,
– t1.account_id,
– t1.msisdn,
– t1.package_id,
– t1.redeem_type,
– (t2.distributor_name) item_category,
– (t2.distributor_name) item_sub_category,
– points_denomination,
– (t1.redeem_type) rdm_type,
– t1.face_value,
– t3.package_description,
– t3.corp_pkg_flag,
– t3.pay_type_code
–FROM
– (
– SELECT time_stamp,
– TO_CHAR(time_stamp, ‘YYYYMMDD’) redemption_date,
– TO_CHAR(trans_ID) trans_ID,
– account_id,
– msisdn,
– package_id,
– ‘Partner’ redeem_type,
– (item_points) points_denomination,
– (item_value) face_value,
– dist_id
– FROM mpay_redeem_trans@lpapp
– WHERE time_stamp >= TO_DATE(SYSDATE - 7) and time_stamp < TO_DATE(SYSDATE)
– AND status = 2
– AND refunded = ‘0’
– AND trans_type = ‘1’
– UNION ALL
– SELECT time_stamp,
– TO_CHAR(time_stamp, ‘YYYYMMDD’) redemption_date,
– TO_CHAR(trans_ID) trans_ID,
– account_id,
– msisdn,
– package_id,
– ‘Partner’ redeem_type,
– (item_points) points_denomination,
– (item_value) face_value,
– dist_id
– FROM mpay_redeem_trans_archive@lpapp
– WHERE time_stamp >= TO_DATE(SYSDATE - 7) and time_stamp < TO_DATE(SYSDATE)
– AND status = 2
– AND refunded = ‘0’
– AND trans_type = ‘1’
– ) t1
–LEFT JOIN mpay_distributor@lpapp t2
– ON t1.dist_id = t2.distributor_id
–LEFT JOIN mgate_package_info@emaprod t3
– ON t1.package_id = t3.package_id;
–COMMIT;
–
–INSERT INTO weeklyTables_log (generation_date, table_name, total_count, unique_msisdn)
–SELECT TO_DATE(SYSDATE) generation_date,
– ‘mpay_redeem_data_temp’ table_name,
– COUNT(*) total_count,
– COUNT(DISTINCT msisdn) unique_msisdn
–FROM mpay_redeem_data_temp;
–COMMIT;
–
–TRUNCATE TABLE weekly_redemption_data_temp;
–
–INSERT INTO weekly_redemption_data_temp (partition_date, time_stamp, redemption_date, trans_ID, account_id, msisdn, package_id, redeem_type, item_category,
item_sub_category, points_denomination, rdm_type, face_value, package_description, corp_pkg_flag, pay_type_code)
–SELECT time_stamp partition_date,
– time_stamp,
– redemption_date,
– trans_id,
– account_id,
– msisdn,
– package_id,
– redeem_type,
– item_category,
– item_sub_category,
– points_denomination,
– rdm_type,
– face_value,
– package_description,
– corp_pkg_flag,
– pay_type_code
–FROM lp_redeem_data_temp
–WHERE rdm_type = ‘Mobily’
– OR (item_sub_category <> ‘EVOUCHER’ AND rdm_type = ‘Partner’)
–UNION ALL
–SELECT time_stamp partition_date,
– time_stamp,
– redemption_date,
– trans_id,
– account_id,
– msisdn,
– package_id,
– redeem_type,
– item_category,
– item_sub_category,
– points_denomination,
– rdm_type,
– face_value,
– package_description,
– corp_pkg_flag,
– pay_type_code
–FROM mpay_redeem_data_temp;
–COMMIT;
–
–
–INSERT INTO weeklyTables_log (generation_date, table_name, total_count, unique_msisdn)
–SELECT TO_DATE(SYSDATE) generation_date,
– ‘weekly_redemption_data’ table_name,
– COUNT(*) total_count,
– COUNT(DISTINCT msisdn) unique_msisdn
–FROM weekly_redemption_data_temp;
–COMMIT;
–
–
–INSERT INTO weekly_redemption_data (partition_date, time_stamp, redemption_date, trans_ID, account_id, msisdn, package_id, redeem_type, item_category,
item_sub_category, points_denomination, rdm_type, face_value, package_description, corp_pkg_flag, pay_type_code)
–SELECT partition_date,
– time_stamp,
– redemption_date,
– trans_id,
– account_id,
– msisdn,
– package_id,
– redeem_type,
– item_category,
– item_sub_category,
– points_denomination,
– rdm_type,
– face_value,
– package_description,
– corp_pkg_flag,
– pay_type_code
–FROM weekly_redemption_data_temp;
–
–COMMIT;
–
–SELECT redemption_date,
– pay_type_code,
– rdm_type,
– points_denomination,
– item_sub_category,
– SUM(points_denomination) total_points,
– COUNT(msisdn) transaction_count,
– SUM(face_value) total_face_value
–FROM weekly_redemption_data_temp
–WHERE corp_pkg_flag = 0
–GROUP BY redemption_date,
– pay_type_code,
– rdm_type,
– points_denomination,
– item_sub_category
–ORDER BY redemption_date,
– pay_type_code,
– rdm_type;
–
–
– 3/20/2015 12:49:15 AM: Script_1.log: Beginning export.
– 3/20/2015 12:50:06 AM: Script_1.log: The process cannot access the file ‘C:\Users\u.gupta.aim\Desktop\Ali\Automation\data_extract\weeklyRedempData2015-03-20 00-
49-13.csv’ because it is being used by another process.
– 3/20/2015 12:50:06 AM: Script_1.log: at Quest.Toad.Workflow.Activities.Database.SelectToExcelActivity.Execute(ActivityExecutionContext executionContext)
– 3/20/2015 12:50:06 AM: Script_1.log: Failed