Solved

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

Posted on 2008-06-18
5
633 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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.
Via a live example, show how to take different types of Oracle backups using RMAN.

732 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