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

Producing a nested output

We have an emp table in Oracle. From that, I need to generate an output like this, for example: john smith sudheer deptno1 300 2400 2500 deptno2 2600 2700 2800. Can this be achived? If so, how?

Hi, we have an emp table in Oracle. From that, I need to generate an output like this, for example: john smith sudheer deptno1 300 2400 2500 deptno2 2600 2700 2800. Can this be achived? If so, how? Please help me in this regard. Thanks in advance.
I believe the question you are asking is how you can produce formatted output from the database. Looking at your output it appears that you are looking for a nested output, so this is how I would approach this.

The choice of simple SQL will not work for you in this scenario. Although quite capable of producing formatted output, the nesting here would cause the issue. Try a select along the lines of:

select  name || ' ' || lpad(emp_no) 
from    emp  

By using this you can get out the output you need. Now to get the nested details you would need to use something like PL/SQL, where you can use some looping to produce the necessary output and using DBMS_OUTPUT. This should provide you with the flexibility to produce what you will need.

Dig Deeper on Oracle business intelligence and analytics

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