Database Tutorial

Course Tutorial Site

Site Admin

Lab #7 : Transactions

with 10 comments

This lab works on developing the students understanding of the syntax to import data from external sources into Oracle and MySQL databases. It also examines the nature of transactions from the perspective of reading and normalizing data from denormalized external sources.

Written by michaelmclaughlin

February 21st, 2010 at 7:59 pm

Posted in

10 Responses to 'Lab #7 : Transactions'

Subscribe to comments with RSS or TrackBack to 'Lab #7 : Transactions'.

  1. Okay I found a fun error:

    SQL> select * from transaction_upload;
    select * from transaction_upload
    *
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04063: unable to open log file transaction_upload.log
    OS error The system cannot find the file specified.
    ORA-06512: at “SYS.ORACLE_LOADER”, line 19

    This one occurred because I had been using the external table tutorial and ran CREATE DIRECTORY download AS ‘C:\Downloads’;
    During the lab I tried renaming C:\Downloads to C:\Download and then the command to CREATE DIRECTORY download AS ‘C:\Download’;

    This caused the error and when I renamed C:\Download to C:\Downloads, it works just fine.

    John G

    4 Mar 10 at 4:02 pm

  2. Brother McLaughlin,

    We have found errors in your account number assignment procedure (well, either that or the CSV). Below are the inconsistencies that have been giving us grief:

    Member Table CSV
    Clinton SLC-000002 SLC-000001
    Moss SLC-000005 SLC-000002
    Royal SLC-000001 SLC-000004
    Smith SLC-000004 SLC-000005

    And then of course the Potters are also being created incorrectly.

    We made manual changes to the member table to correspond with the CSV, and we got good results. The issue is either that the CSV has the wrong values, or the procedure being used to assign account numbers is off. This has been causing problems because of the account_number comparison being used whenever joining member-contact to transaction_upload.

    We may be very off, but I think this is the issue. thanks.

    Skyler

    8 Mar 10 at 11:09 pm

  3. We kinda hacked together a fix by just removing the m.account_number =tu.account_number comparison being used in our merge statement joins. This gives us 4681 WITHOUT using a GROUP BY statement. I dont know how accurate this data is; my understanding of the theory isnt sound enough to know for sure. Please advise. thanks.

    Skyler

    8 Mar 10 at 11:15 pm

  4. I’ve posted some added checks. There shouldn’t be anything wrong with the *.csv file. Other students have this working.

    michaelmclaughlin

    8 Mar 10 at 11:42 pm

  5. Assuming that you’re referencing the 3rd query (or MERGE statement), that would not work because it’ll fail to aggregate rental_item amount values to rental amount values.

    michaelmclaughlin

    8 Mar 10 at 11:43 pm

  6. None of the transaction dates in the MySQL .csv are in 2009.

    Wil G.

    10 Mar 10 at 2:07 am

  7. Oops! I’ll fix it. I’m not sure what happened.

    michaelmclaughlin

    10 Mar 10 at 9:54 am

  8. 2nd line in the objective statement at the top has an extra the “and the you should”.

    Chaz

    15 Jun 10 at 1:09 pm

  9. Fixed. Thanks Chaz.

    michaelmclaughlin

    21 Jun 10 at 9:43 pm

  10. Here’s a correlated update statement that will update all the rental_item_type values to correct rows after inserting the values for the rental_item table into common_lookup:

    update rental_item ri
    set rental_item_type =
    (select cl1.common_lookup_id
    from common_lookup cl1
    where cl1.common_lookup_table = ‘RENTAL_ITEM’
    and cl1.common_lookup_column = ‘RENTAL_ITEM_TYPE’
    and cl1.common_lookup_type =
    (select cl2.common_lookup_type
    from common_lookup cl2 inner join price p
    on p.price_type = cl2.common_lookup_id inner join rental r
    on r.check_out_date between p.start_date and NVL(p.end_date, sysdate)
    where p.amount = ri.rental_item_price
    and ri.item_id = p.item_id
    and cl2.common_lookup_id = ri.rental_item_type
    and r.rental_id = ri.rental_id));

    Tyler

    15 Mar 11 at 1:48 pm

Leave a Reply