Solved

Need procedure assistance

Posted on 2012-04-09
2
210 Views
Last Modified: 2012-06-27
Good evening,

I have two tables one is BASE_TABLES with table_id, table_name, and a few other cols.
The other is BASE_TABLE_COLS  with table_id, col_name, col_Alias

I would like to build a query based on the requisite table columns of the base tables.

that would be something like  'select '||col_name1||' , '||col_alias1||' ,...'||col_n||' from '||base_table ;
How could I build that query string in the procedure then execute into a ref_cursor?

Any assistance would be greatly appreciated.
0
Comment
Question by:Focker513
2 Comments
 
LVL 16

Accepted Solution

by:
Wasim Akram Shaik earned 500 total points
ID: 37826459
check in this site, you can see how to use a refcursor

http://www.oracle-base.com/articles/misc/using-ref-cursors-to-return-recordsets.php

and for your code, you just have to use dynamic sql for using refcursor..

just posting a sample reference code. you can make the prepare the whole code basis on this approach

ie., store the sql in a variable

declare
cur_contr_details refcursor;
v_var varchar2(1000);
begin
v_var:= 'select '||col_name1||' , '||col_alias1||' ,...'||col_n||' from '||base_table ;
  OPEN cur_contr_details FOR v_var;

....
OPEN cur_contr_details FOR sql_stmt1 USING i.sncode;
0
 
LVL 2

Expert Comment

by:datakeyword
ID: 37826654
why not try esProc to solve it?
esProc is a tool for mass data computation, especially fit for the complex data computation like yours.
Check below for more details :http://www.esproc.com/library/product/bid-farewell-to-stored-procedure.html
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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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 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…
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.

770 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