Home » SQL & PL/SQL » SQL & PL/SQL » Procedure creation help
Procedure creation help [message #680417] Wed, 13 May 2020 13:53 Go to next message
chavva.kiru@gmail.com
Messages: 22
Registered: April 2012
Location: hyderabad
Junior Member
Hi,

I want to create a procedure in such a way that I want to pass a table name to a procedure,It has to return table o/p.How can we create that procedure?

Re: Procedure creation help [message #680420 is a reply to message #680417] Wed, 13 May 2020 13:57 Go to previous messageGo to next message
BlackSwan
Messages: 26733
Registered: January 2009
Location: SoCal
Senior Member
chavva.kiru@gmail.com wrote on Wed, 13 May 2020 11:53
Hi,

I want to create a procedure in such a way that I want to pass a table name to a procedure,It has to return table o/p.How can we create that procedure?

This is a Bad Plan.
How does the call procedure know the number of returned columns in the row & the datatype for each of the columns?

What problem are you really trying to solve?
Re: Procedure creation help [message #680421 is a reply to message #680420] Wed, 13 May 2020 14:00 Go to previous messageGo to next message
chavva.kiru@gmail.com
Messages: 22
Registered: April 2012
Location: hyderabad
Junior Member
Hi,

Yesterday one of my friend asked me she said we will do it by refcursor and dynamic sql
can you please help how can we do it

regards,
kiran chavva

Re: Procedure creation help [message #680424 is a reply to message #680417] Wed, 13 May 2020 14:19 Go to previous messageGo to next message
Michel Cadot
Messages: 67369
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
From one of your previous topics:

Michel Cadot wrote on Tue, 22 October 2019 21:34

From your previous topics:

Michel Cadot wrote on Tue, 01 October 2019 20:09

From your previous topic:

Michel Cadot wrote on Wed, 25 September 2019 08:04

From your previous topics:

Michel Cadot wrote on Wed, 25 September 2019 08:03
Michel Cadot wrote on Thu, 06 October 2016 07:30

From your previous topic:

Michel Cadot wrote on Mon, 19 January 2015 07:22

From your previous topic:

Michel Cadot wrote on Thu, 16 August 2012 16:20
From your previous topics:

BlackSwan wrote on Wed, 11 April 2012 16:43
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
BlackSwan wrote on Wed, 11 April 2012 20:29
...
READ & FOLLOW the Posting Guidelines! http://www.orafaq.com/forum/t/88153/0/
With any SQL question, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel
In addition, Barbara helped you so much in your previous topics providing you codes and examples and you did never feedback and thank her.
Are you the kind of parasite we saw too much in these days?
Or are you a valuable person who deserves to be helped?

[Updated on: Wed, 13 May 2020 14:20]

Report message to a moderator

Re: Procedure creation help [message #680426 is a reply to message #680421] Wed, 13 May 2020 14:49 Go to previous messageGo to next message
BlackSwan
Messages: 26733
Registered: January 2009
Location: SoCal
Senior Member
chavva.kiru@gmail.com wrote on Wed, 13 May 2020 12:00
Hi,

Yesterday one of my friend asked me she said we will do it by refcursor and dynamic sql

This is a good learning experience so get with your friend & make it do as you desire.
Re: Procedure creation help [message #680429 is a reply to message #680426] Thu, 14 May 2020 00:16 Go to previous messageGo to next message
chavva.kiru@gmail.com
Messages: 22
Registered: April 2012
Location: hyderabad
Junior Member
Its an interview question which i have faced 2 days before
Re: Procedure creation help [message #680443 is a reply to message #680429] Thu, 14 May 2020 07:33 Go to previous messageGo to next message
BlackSwan
Messages: 26733
Registered: January 2009
Location: SoCal
Senior Member
chavva.kiru@gmail.com wrote on Wed, 13 May 2020 22:16
Its an interview question which i have faced 2 days before

Then you no longer need any answer. If you only missed 1 question, then you should be OK.
Re: Procedure creation help [message #680447 is a reply to message #680443] Thu, 14 May 2020 10:15 Go to previous messageGo to next message
chavva.kiru@gmail.com
Messages: 22
Registered: April 2012
Location: hyderabad
Junior Member
The interviewer told me that we have to use ref cursor and dynamic sql ,what i guessed as below

create or replace procedure abc( a tablename,out c1) as
begin
TYPE SalTabTyp IS TABLE OF a%TYPE
INDEX BY BINARY_INTEGER;
type auth_cursor is ref cursor;
c1 auth_cursor;
c1 %rowtype;
begin
open c1 for select * from a;
execute immediate create table a as c1;
end;
/

[Updated on: Thu, 14 May 2020 10:16]

Report message to a moderator

Re: Procedure creation help [message #680448 is a reply to message #680447] Thu, 14 May 2020 10:55 Go to previous message
Michel Cadot
Messages: 67369
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

The interviewer or your friend?

More than 8 years to write PL/SQL and you are at level 0!
As you are at level -∞ to post in this forum.

Previous Topic: Creation of new partitions by increasing the sequence number
Next Topic: Transposing data in single row
Goto Forum:
  


Current Time: Thu Sep 24 04:17:47 CDT 2020