473,480 Members | 3,135 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamic Cursor Generation..

Hi Everybody,
I have a probs with dynamic generation.
I am writing the probs
======================================
create proc test
as
declare @query varchar(500)
set @query = 'select * from table'
----------------------------------------------
declare mycur Cursor for Select * from table |
open mycur |
----------------------------------------------
but instate of above block how can I dynamically generate this query?
---------------------------------------
declare mycur Cursor for exec (@query) |
---------------------------------------
Or tell me the way.
Regards
Arijit Chatterjee
Jul 20 '05 #1
2 2873
hi, the problem was not clear what u want to do dynamiclly.
if u want to ftech rows thru proc, u can code like

create proc test
as
use db
exec(select * from table)
this might work

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #2
On 4 Nov 2003 21:04:27 -0800, ar*****************@yahoo.co.in (Arijit
Chatterjee) wrote:
but instate of above block how can I dynamically generate this query?
---------------------------------------
declare mycur Cursor for exec (@query) |
---------------------------------------
The way I've done stuff like this in the past is to stuff the results
into a temp table and run a cursor off that.

Example:
declare @SQLstring varchar(100)
create table #foo (foovar int)

select @SQLString = 'select distinct foovar from footable'

insert into #foo exec(@SQLString)

declare foo_cursor for select distinct foovar from #foo
etc.

Obviously you really want to do this type of stuff when there is no
other way around it.
Or tell me the way.
Regards
Arijit Chatterjee

Jul 20 '05 #3

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

Similar topics

1
7396
by: Kevin Frey | last post by:
Hello, I have a test database with table A containing 10,000 rows and a table B containing 100,000 rows. Rows in B are "children" of rows in A - each row in A has 10 related rows in B (ie. B has...
0
1542
by: Shailesh | last post by:
If I'm not mistaken, C++ doesn't have support for dynamic class members. I'm considering if such a facility would be useful, and what method would make a good workaround. I have a generic...
5
18647
by: Joško Šugar | last post by:
On this site: http://www.sommarskog.se/dynamic_sql.html I have found an example how to use cursor with dynamic SQL: DECLARE @my_cur CURSOR EXEC sp_executesql N'SET @my_cur = CURSOR FOR SELECT...
5
6158
by: Todd Huish | last post by:
I have noticed something disturbing when retrieving datasets over a relatively slow line (multiple T1). I am looking at about 25 seconds to retrieve 500 rows via a php-odbc link. This same select...
1
34939
by: Todd Peterson | last post by:
I'm a newbie to DB2 and am trying to figure out how to write a stored procedure, using dynamic SQL statements to return a result set. I believe the majority of the hurdles I have been facing might...
11
4702
by: Marco Loskamp | last post by:
Dear list, I'm trying to dynamically generate functions; it seems that what I really want is beyond C itself, but I'd like to be confirmed here. In the minimal example below, I'd like to...
2
3064
by: Ghada Al-Mashaqbeh via DotNetMonster.com | last post by:
Hi all, I am facing a problem in dynamic code generation at run time, the problem occurs when the dynmaic code use global data exist within the original application. Lets say that my...
5
3137
by: pittendrigh | last post by:
There must be millions of dynamically generated html pages out there now, built by on-the-fly php code (and jsp, perl cgi, asp, etc). Programatic page generation is transparently useful. But...
0
865
by: J. Cliff Dyer | last post by:
On Thu, 2008-05-08 at 10:33 -0500, Victor Subervi wrote: Why are you dynamically creating getpic20.py? Obviously, in the real script, you probably have several of them: getpic1.py, getpic2.py,...
0
7055
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,...
0
7110
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...
1
6763
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...
0
7030
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...
1
4799
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...
0
4503
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3015
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...
0
3011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
210
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...

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.