473,791 Members | 2,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic tablename with %rowtype

Sri
how to handle a situation where i wnt a variable of type ref cursor.

TYPE refCur IS REF CURSOR;
rc refCur;

myRow rc%rowtype; -- How can I make this work???

The whole problem is that only on run time I am able to know the table
on which i have to work. So I have created a Ref Cursor

BEGIN
sqlStmt := 'select * from ' || mytable; -- mytable is stored in one
of the table in the database. depending on the parameter passed to
the proc the table name is retrived.

OPEN rc FOR sqlStmt;
LOOP
FETCH rc into myRow; -- ??? I want to fetch the data from the
cursor in a rowtype of the table - mytable. how to handle this
situation.
....
....
END LOOP;
END;

please guide me... as to how can i make a variable of my cursor
rowtype. i am in urgent need of a solution asap.
thanks

Sri
Jul 19 '05 #1
1 11869
ko******@hotmai l.com (Sri) wrote in message news:<3f******* *************** ****@posting.go ogle.com>...
how to handle a situation where i wnt a variable of type ref cursor.

TYPE refCur IS REF CURSOR;
rc refCur;

myRow rc%rowtype; -- How can I make this work???

The whole problem is that only on run time I am able to know the table
on which i have to work. So I have created a Ref Cursor

BEGIN
sqlStmt := 'select * from ' || mytable; -- mytable is stored in one
of the table in the database. depending on the parameter passed to
the proc the table name is retrived.

OPEN rc FOR sqlStmt;
LOOP
FETCH rc into myRow; -- ??? I want to fetch the data from the
cursor in a rowtype of the table - mytable. how to handle this
situation.
....
....
END LOOP;
END;

please guide me... as to how can i make a variable of my cursor
rowtype. i am in urgent need of a solution asap.
thanks

Sri

I don't think you can do this dynamically with straight PL/SQL code.
But take a look at the Oracle supplied package DBMS_SQL. It may allow
you to do this, or accomplish the same thing in a different way.

Dave
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1557
by: dave | last post by:
I am trying to run 3 dynamic selects from stored proc, really only the table name is dynamic.. Anway I'm kinda lost on how I can accomplish this.. this is what I have but it only returns the first result.. that being basic CREATE PROCEDURE email_complexity @TableName VarChar(100) AS
4
7144
by: ezra epstein | last post by:
Aother head banger for me. Below is a complete example of the code Using Postgres 7.4, the function "test" gets this: psql:temp3.sql:10: ERROR: syntax error at or near "%" at character 135 the function "test2" gets this: psql:temp3.sql:10: ERROR: syntax error at or near "ROWTYPE" at character 141
9
11481
by: DeepHalo | last post by:
I want to do simply this in MS Access. PARAMETERS pTableName; SELECT * FROM pTableName; This doesn't work ( if it did I wouldn't ask you :) ) but is it clear what I want to do? Just with passing table names or columns as
0
2386
by: K B | last post by:
PLEASE be patient and read this. I believe I've actually reached the end of the Web trying to find the answer! I have an aspx using a MasterPage with a ContentPlaceholder. I have a datatable that I use to dynamically populate a gridview - I have to do this in order to specify which control type to put in one of the columns. All this works fine. I've run Trace and can clearly see that the control.id I assigned (lblQuestionID) is there...
3
4297
by: meeko | last post by:
hi, i am trying to create a dynamic sql to compare the old and new values in a table by usind a procedure as follows The g_o_rec and g_n_rec are global variables declared at the package level When I execute this, it always goes into exeception with the following error sqlerrm ORA-00904: "G_N_REC"."PHONE": invalid identifier sqlerrm ORA-00904: "G_N_REC"."CONTACT_PHONE": invalid identifier sqlerrm ORA-00904: "G_N_REC"."WEBPAGE_URL":...
1
2164
by: baskarp | last post by:
How do I do dynamic %ROWTYPE
1
1718
by: kalyson | last post by:
Hello, I realize that using the TYPE declaration for variables makes their definitions more dynamic, like this: myField tablename.name%TYPE; myRow tablename%ROWTYPE; But I also want to be able to change the name of the table in the code. So I want to have "tablename" above refer to a VARIABLE that contains the name of a table, so I don't have to go changing the tablename throughout the code if the table name...
1
265
by: Sri | last post by:
how to handle a situation where i wnt a variable of type ref cursor. TYPE refCur IS REF CURSOR; rc refCur; myRow rc%rowtype; -- How can I make this work??? The whole problem is that only on run time I am able to know the table on which i have to work. So I have created a Ref Cursor
0
2729
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only, cannot serch by combine 3 table) Example I have the query table below, how do I make the code to seach based on the query from this: SELECT Product.ID, Product.Description, Quantity.Quantity, Quantity.SeialNo, Quantity.SupplierID,...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.