473,382 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Create a cursor and fill it dynamically

Hi,

It's probably easiest if I describe what I'm trying to do:

I have several tables I want to base a query on. In addition I have
some dynamic data that I want to join against that consists of several
records of information.

I could just create a temp table of the dynamic data and join it
against my tables, but I thought there was a way to create a cursor
(not based on a table i.e. with a select statement), fill it with the
dynamic data, and join the cursor against the other tables to get my
desired results.

The reason I wanted to do it this was for performance. I'd rather not
incur the hit of writing a temp table to a hard drive, so I thought
the cursor would keep it in memory (of course as long as it doesn't
force memory to get paged out to disk).

I'm not that familiar with DB2. I've read a little about temporary
tables and the temporary global table space. Would using a temp table
be more efficient than my proposal? If so, could you please explain
why? Does the DB not write a temp table to disk if it doesn't need to?

Thanks very much in advance,
William G. Yoder
Nov 12 '05 #1
3 3835

"Wiggy" <sp*****@yoder.org> wrote in message
news:cd**************************@posting.google.c om...
Hi,

It's probably easiest if I describe what I'm trying to do:

I have several tables I want to base a query on. In addition I have
some dynamic data that I want to join against that consists of several
records of information.

I could just create a temp table of the dynamic data and join it
against my tables, but I thought there was a way to create a cursor
(not based on a table i.e. with a select statement), fill it with the
dynamic data, and join the cursor against the other tables to get my
desired results.

The reason I wanted to do it this was for performance. I'd rather not
incur the hit of writing a temp table to a hard drive, so I thought
the cursor would keep it in memory (of course as long as it doesn't
force memory to get paged out to disk).

I'm not that familiar with DB2. I've read a little about temporary
tables and the temporary global table space. Would using a temp table
be more efficient than my proposal? If so, could you please explain
why? Does the DB not write a temp table to disk if it doesn't need to?

A table function may be a better solution to your problem. They are capable
of reading data that is not in a DB2 table, such as in a flat file or some
other format. You can then join data found by the table function to other
data from DB2 tables.

I don't recall how table functions handle memory and/or disk space but it
should be in the DB2 manuals somewhere.

Rhino
Nov 12 '05 #2
In article <cd**************************@posting.google.com >, Wiggy
(sp*****@yoder.org) says...
Hi,

It's probably easiest if I describe what I'm trying to do:

I have several tables I want to base a query on. In addition I have
some dynamic data that I want to join against that consists of several
records of information.


Something like this:

WITH temp1 (col1, col2, col3) AS
(VALUES ( 0, ?AA?, 0.00),
( 1, ?BB?, 1.11),
( 2, ?CC?, 2.22)
)

This example is copied from Graeme Birchall's SQL Cookbook which you
can find at
http://ourworld.compuserve.com/homep...l/HTM_COOK.HTM

Hope this helps.
Nov 12 '05 #3
Gert & Rhino. Thanks very much for the responses!

sp*****@yoder.org (Wiggy) wrote in message news:<cd**************************@posting.google. com>...
Hi,

It's probably easiest if I describe what I'm trying to do:

I have several tables I want to base a query on. In addition I have
some dynamic data that I want to join against that consists of several
records of information.

I could just create a temp table of the dynamic data and join it
against my tables, but I thought there was a way to create a cursor
(not based on a table i.e. with a select statement), fill it with the
dynamic data, and join the cursor against the other tables to get my
desired results.

The reason I wanted to do it this was for performance. I'd rather not
incur the hit of writing a temp table to a hard drive, so I thought
the cursor would keep it in memory (of course as long as it doesn't
force memory to get paged out to disk).

I'm not that familiar with DB2. I've read a little about temporary
tables and the temporary global table space. Would using a temp table
be more efficient than my proposal? If so, could you please explain
why? Does the DB not write a temp table to disk if it doesn't need to?

Thanks very much in advance,
William G. Yoder

Nov 12 '05 #4

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

Similar topics

3
by: robert | last post by:
Mr. Kyte's article doesn't use cursors, while Mr. Feuerstein's book examples do. my recollection of conventional wisdom is to avoid using cursors. is this difference merely a question of style,...
9
by: Gary Holt | last post by:
We have a problem demonstrated by the following HTML document. To see the problem type HV in the first field then use the mouse cursor to click into the Staff code input box. You will find that...
1
by: citytroop | last post by:
Hi I am creating a form for vieweing and editing faxes. I read the fax tiff file into the picturebox. And I have two problems: 1.I want to add a function for the users to be able to select an...
1
by: Onur Bozkurt | last post by:
I have a form to fill which has textbox's and dropdownlist's, but I don't know how many of them will the user fill on a page. So I want to give the number dynamically. I created a form and used...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
2
by: Alexander Vasilevsky | last post by:
Hi! How to create the coloured mouse cursor dynamically? -- http://www.alvas.net - Audio tools for C# and VB.Net developers
0
by: malsh1358 | last post by:
I created Jaxb java classes and now I want to fill them dynamically , but I dont know how I can dynamically fill JAXB java objects (I can do it in fix way) ,I must say that their data are in xml file...
4
by: srikkanthms09 | last post by:
Hai Hai I need to generate a daily attandence report. My file is in text format so i need to create a cursor and generate these values dynamically in forms6i. I have create a browse button...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.