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
Solved

Need procedure assistance

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

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…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

839 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