"Ian S. Worthington" wrote:
> What I don't appear to be able to get right is the trivial bit: Files STARTLU
> and START000 need to be fanned together into a single file, but all my
> attempts to do so seem to end in label redefinition hell.

I'm guessing what you're probably missing is that you need a FANOUT to
make two copies of file START000, one to feed to LOOKUP and the other to
fan into your output:

'PIPE (end ?)',
   '        <' fn '    other    ' ofm,
   '|start: nlocate 41.5 ,START,   ',
   '|nstart:  faninany          ',
   '|       buffer',
   '|l2:      lookup 18.8 detail',  /* details in; matches on luname,
                                       write detail records */
   '|add0: fanin 1 0',
   '|         >' fn '  startlu '  ofm,
   '?start:',
     '|0000:  nlocate 33.4 ,0000,     ',
     '|nstart:',
   '?0000:',
     '|dup0: fanout' ,
     '|l2:',                      /* masters in; unref details out */
     '|       >' fn 'nstartlu'      ofm,
   '?dup0:',
     '|add0:'

I used BUFFER instead of ELASTIC because there's no need to try to read
any of the file before EOF on the input.(*)  Note that the entire master
file will come at the top of your output.  If you want the records in
the original order, since your LOOKUP compares the same columns in the
detail and master records, you can feed the master records back into the
file before the LOOKUP instead of after, and they'll always be selected:

...
   '?dup0:',
     '|nstart:'

If your input file is on disk, though, you might as well just read it
twice instead, since reading a file from disk a second time with < is
generally cheaper than buffering it in storage:

'PIPE (end ?)',
   '        <' fn '    other    ' ofm,
   '|l2:      lookup 18.8 detail',  /* details in; matches on luname,
                                       write detail records */
   '|         >' fn '  startlu '  ofm,
   '?       <' fn '    other    ' ofm,
     '|       locate 41.5 ,START,',
     '|       locate 33.4 ,0000,     ',
     '|l2:',                      /* masters in; unref details out */
     '|       >' fn 'nstartlu'      ofm

(*) ELASTIC generally says to me, "This is stalling and I don't know
    why, so I'll just keep throwing in slop until it runs."  There are
    specific situations where it's really needed, but usually either 
    BUFFER or COPY is more appropriate.

    Also, the lowercase "pipe" indicates that you must not be using
    ADDRESS COMMAND, so you'll stumble on any execs with the same name
    as commands you're issuing.  Every time I think I should rename my
    PIPE EXEC, I decide it's worth keeping around to detect this and
    alert exec authors to it--especially since I tend to inherit a lot
    of the code I use.

¬R

Reply via email to