Q
Problem solve Get help with specific problems with your technologies, process and projects.

Showing all transactions under a single listing

I have two tables: customer_data and customer_transactions. How can I get all the transactions to show under a single listing of the customer data, i.e., firstname, lastname, address followed by transaction_1, transaction_2 .....transaction_n?

There are two ways to do it. First, you can create a temporary table with all the columns you need. You must assume a maximum number of transactions per customer. For example, if 10 transactions are allowed, then the table structure will be:

FirstName,
LastName,
address,
TRANS1,TRANS2,......TRANS10
Then you write a PL/SQL block with two cursors: outer cursor for customer_data and inner cursor for customer transaction per current outer customer, and fill the temp table in the nested loop.

The second way is to do the same thing, but instead of inserting to a temp table, store it to an output line and use DBMS_OUTPUT to print the results. In this method, a maximum number of transation can vary.

For More Information


Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close