By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,018 Members | 930 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,018 IT Pros & Developers. It's quick & easy.

materialze query?

P: n/a
Hi!

I'm writing a program that interacts with a db2 database through jdbc.
I frequently need to run a quite query q1 that involves several full
outer join of a table with itself. Once q1 is executed I need to
postprocess the result. This postprocessing involves several queries on
the result of q1. I think that the best solution would be to
materialize the result of q1 in the database. How can I do it?

Thanks a lot in advance!

Diego
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Diego,

may be you check out the following:

- cursor: DECLARE CURSOR FOR 'SELECT ... FROM ...'
then you can fetch the results and moe within your cursor and do your logic
for each result found, can be hold over transaction scope.

- temporary tables: DECLARE GLOBAL TEMPORARY TABLE ...
a temp table which exists within one transaction

- MQT (materialized query table): CREATE TABLE ... AS 'SELECT .. FROM...'
DATA INITIALLY DEFERRED REFRESH IMMEDIATE ...

this calculated table actually does physically exist and will be used when a
user issues a join which is specified in the FROM clause of the SELECT
statement, it can also be accessed directly, just as you declare it.
Refreshing on request or automated possible

choose what is best for you, a MQT is probably best to reuse.
But, if you have to query just once, may be you open a cursor and for each
item you fetch do your processing ?

Hope that helps

Juliane

gordongekko wrote:
Hi!

I'm writing a program that interacts with a db2 database through jdbc.
I frequently need to run a quite query q1 that involves several full
outer join of a table with itself. Once q1 is executed I need to
postprocess the result. This postprocessing involves several queries on
the result of q1. I think that the best solution would be to
materialize the result of q1 in the database. How can I do it?

Thanks a lot in advance!

Diego

--
Message posted via http://www.dbmonster.com
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.