Solved

How do i generate a MDX query in Oracle 9i?

Posted on 2008-06-18
5
630 Views
Last Modified: 2013-12-19
I have 2 tables APPLICATIONS and APPLICATION_COLUMNS

1. APPLICATIONS has 25 Flex fields namely C01, C02, C03 ,etc.
2. The table APPLICATION_COLUMNS tells which Flex Fields needs to be displayed.
This data in this table will be stored as this.
Column Name | Field Name | Description|
1.C01|Columns Name|Some Description|
2.C02|Columns Name|Some Description|
3.C03|Columns Name|Some Description|

Now depending on the existence of this Column Name i.e. C01\C02\C03 in the above table APPLICATION_COLUMNS,I need to display those flex fields from APPLICATIONS table.

Let me know if more information is needed

Thanks

0
Comment
Question by:P_Ramprathap
  • 3
5 Comments
 
LVL 22

Accepted Solution

by:
DrSQL earned 250 total points
ID: 21812752
P_Ramprathap,
     It would have to be dynamic.  You can't translate a value into a column reference in the same query.  But, you can build your query using the "application_columns" table.  If you're using SQL*Plus you can generate the query into a file using the spool command and then execute it.  If you're using pl/sql or a programming language you'd build a string and then execute it according to the dynamic SQL approach you prefer (note that execute immediate would need to have a set number of columns returned).  Here's an untested SQL*Plus approach:

set head off
set timing off
set time off
set sqlprompt off
set lines 100
set pages 0
set show off
set verify off
col segment noprint

select 1 segment,decode(column_name,'C01','select <id columns>,', ', ') || column_name || ' as ' ||
          field_name
from application_columns
union all
select 2, '  from applications;' from dual

spool myquery.sql
/
spool off

set pages 40
set head on
set timing <whatever you normally use>
set time <whatever you normally use>
set sqlprompt on
set lines <whatever you normally use>
set show on
set verify o
start myquery
0
 
LVL 22

Expert Comment

by:DrSQL
ID: 22088356
P_Ramprathap,
    It's been over a month.  Could you please update this question?  Thank you for using Experts Exchange.

Good luck!
0
 
LVL 22

Expert Comment

by:DrSQL
ID: 22102864
P_Ramprathap,
    Sorry, but a "no" answer and a proposal of another approach does not mean that you didn't receive fair value for your question.  I explained the limitation (that you were not aware of) and showed you a method to use.  That's a legitimate answer.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question