473,804 Members | 3,185 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 11870
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
2388
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
2730
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
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10562
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
10319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
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...
1
7608
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
5508
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...
1
4282
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
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.