sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Doing a search on a PF and a LF and displaying both in one subfile

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Doing a search on a PF and a LF and displaying both in one subfile

    My program is supposed to accept an input which may be found in either of two fields in a PF and I need to display all records where the input is in either fields.

    For example:
    The user enters a value, say ORD12.
    I have a cross reference file which includes COLUMN1 and COLUMN2. The use of COLUMN1 and COLUMN2 is not consistent so depending on what another program writes ORD12 may be in either COLUMN1 or COLUMN2.
    My program needs to display all records where ORD12 appears in either COLUMN1 or COLUMN2.

    The cross reference file is a PF with COLUMN1 as the Key and I created an LF with COLUMN2 as the key.

    Is there a way to display the results of the search using the PF and the search using the LF?

  • #2
    Hi, Justin.

    I think keys will be irrelevant here. It sounds to me that ORD12 can be anywhere in those columns, not always the first characters.

    I would use SQL, and I would use the LIKE predicate with OR, like this: (not tested)

    Code:
    select . . . from ThePF
    where column1 like ('%ORD12%') or column2 like '%ORD12%')
    except that you'll have to use a variable instead of the hard-coded value.

    You can also concatenate column1 and column2 and test that with LIKE.

    Code:
    where column1 concat column2 like '%ORD12%'
    Performance of the two will probably be about the same. Either way, the optimizer is going to scan the table.

    I'm sorry I can't give you better syntax, but I don't have a COBOL compiler or sufficient time at the moment. I hope it helps.

    Ted

    Comment

    Working...
    X