Date:         Wed, 15 Feb 1995 09:22:00 +0000
Reply-To:     The NOMAD2 Discussion List
Sender:       The NOMAD2 Discussion List
From:         Kuen-Yih Chang
Subject:      How to select multiple-key master using arrays?

The question is simple: I have those key values in arrays. How can I
select records with these key values?

I have a master with 3 key items (let's make it 2 keys for example
and name these key1, key2).

     MASTER sample INSERT=KEYED( KEY1, KEY2);

And I have 2 arrays &x_key1, &x_key2.  These two 1-dimentional arrays
hold the key values of those records I want in the master, e.g.,
&x_key1(14) and &x_key2(14) together is the key of the 14th record I
want.  If the master has only one key item, I can simply use

     SELECT key1 among(constant(&x_key1));

But with multiple keys,

     SELECT key1 among(constant(&x_key1)) and
            key2 among(constant(&x_key2));

this select will pick up records with key1 and key2 referring to
different elements of &x_key1 and &x_key2.

Let's look at sample data:

   Master            Array     Array
   key1   key2       &x_key1   &x_key2
   0001   101        0001      102
   0001   102        0002      101
   0002   101
   0002   102

Obviously I want records 2 and 3 in the master. But with previously
SELECT command, all 4 records will be selected. I try to find an
efficient way to do this select. I doubt the efficiency of

    SELECT DISPLAY(key1)    CAT DISPLAY(key2)
     AMONG(DISPLAY(&x_key1) CAT DISPLAY(&x_key2))

I have to use SELECT. Because after this SELECT there might be
lots more SELECT ADD. That is, loop process of the arrays is not in
consideration.

Any suggestion, solution, or question on this question is welcome.
+------------------------------------+
|           Kuen-Yih Chang           |
|       Data Processing Analyst      |
|    Southern Illinois University    |
|   School of Medicine-Springfield   |
|       email:kchang@siumed.edu      |
+------------------------------------+
back to index