Solved

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

Posted on 2008-06-18
5
628 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
Comment Utility
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
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now