Solved

Need procedure assistance

Posted on 2012-04-09
2
208 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.

Join & Write a Comment

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

747 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

10 Experts available now in Live!

Get 1:1 Help Now