top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

PL/SQL block which will populate the RESULTS table

0 votes
462 views

Question: Write a PL/SQL block which will populate the RESULTS table as described below. Consider performance implications (specifically where would you commit the queries) as we are dealing with millions of records.

The PL/SQL will:
• Insert into the RESULTS table each customer id, and the number of unique products purchased by that customer.
• Update the recently purchased column of the customer table to 'Y' (yes if they have purchased a product in the last 12 months) or 'N' (if they have not purchased a product in the last 12 months).

Listed below are the tables & definitions:

Table: CUSTOMER Columns: customer_id NUMBER, customer_name VARCHAR2(100), recently_purchased VARCHAR2(1) -- 'Y' or 'N'
Table: CUST_PRODUCTS columns: product_id NUMBER, customer_id NUMBER, date_purchased DATE
Table: RESULTS columns: customer_id NUMBER, product_count NUMBER
posted Jun 27, 2014 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
Seems to be homework please check the following link
http://www.dbasupport.com/forums/showthread.php?60723-PL-SQL-block-to-populate-a-table

Exact solution is already there.
the answer there  is not comprehensive enough or not accurate
Can you be bit descriptive what is not working?
Though I don't see any issue other then update statement where loop is not required, you can just remove the loop.
the solution does not look professional
I don't see any issue here, we at queryhome also do in the very similar way. Only issue was update which was running multiple times.. Else you need to point out what does not look professional.
can you please rephrase your question. lack details

-Arun

...