Solved

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

Posted on 2008-06-18
5
632 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can i Import Access Table Into Oracle Using Toad 36 276
PL/SQL Two changes 7 41
Oracle Insert not working 10 48
sum of columns in a row in oracle 3 42
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

756 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