complex joins and temp tables
Posted in 1993
Pholks,
I'm doing a Bill Of Materials (BOM) explosion in 4gl. Normally this is a
recursive thing:
Assembly1
part01
part02
subassy1
part11
part12
subassy2
part21
part13
subassy3
part03 .... and so on
As you hit a subassembly you explode it. Since I can't use a cursor
recursively, and I don't care to preserve the layout (just want the
parts). I run through the first assembly completely and load it into an
array with cursor1 (select * where assembly = ?). Then I walk through
this array, each time I hit a subassembly I re-open cursor1 and stick the
results on the end of the array. So I get:
Assembly1
part01
part02
subassy1
part03
part11 (from subassy1)
part12
subassy2
part13
subassy3
part21 (from subassy2)
When my walk through hits the end of the array I know that I've exploded all
the subassemblies. So far so good - it works fine. The problem is the
cursor. There are a number of rules built into it:
select fields from table
where assembly = ?
and other stuff
and NOT EXISTS (select fields from other_table
where (4 joining fields to first table) )
The fourth joining field is forcing the engine to create a temp table.
This in itself is not a problem, but we just started (aha!) an integrity
report against the entire database which explodes EACH AND EVERY ASSEMBLY.
So I have to get a list of assemblies - and for each one do this walk thing.
This implies that I'm going to create ca. 7500 temp tables.
It froze up yesterday when I ran it for the first time. The problem? I
had filled the logfiles with 'create temp table' log entries from the
cursor. We don't do logging. We don't backup our logs. But schema changes
appear to be always logged regardless.
I've already come up with a jury-rig which involves not doing the join
through 4gl, but loading the second table into memory and flagging matched
rows for non-inclusion. My question is - can I get the cursor NOT to log
the temp tables it creates?
working around stuff in Boise
j.
_____________________________________________________________________________
Jack Parker |
Hewlett Packard, BSMC Boise, Idaho, USA| Your .sig has expired, please enter
jparker@hpbs2561.boi.hp.com | a new one.
(208) 396-5388 (W) (208) 384-1623 (H) |
_____________________________________________________________________________
Any opinions expressed herein are my own and not those of my employers.
_____________________________________________________________________________