×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

CHAIN Operation results in more than 1 row

CHAIN Operation results in more than 1 row

CHAIN Operation results in more than 1 row

(OP)
I've come up against situations where records were not processed because there were more than 1 result to a chain operation.

The program I'm working on now generates an error report when records are not processed. The program doesn't catch the error when a Chain operation results in 2 or more rows. I need some way to catch this error. Any ideas?

Thanks in advance and Merry Christmas!

RE: CHAIN Operation results in more than 1 row

you could change the logic, to do a SETLL do a READE, and process the records until the READE returns an error,,  

RE: CHAIN Operation results in more than 1 row

There can't be more than one record returned with a chain. By definition is gets a single record by key. If there are multiple records by key, then do as jmd said. Use a loop to read thru the records using READE. Use SETLL to set the file at the first record that meets the key and use READE to read them by key.

 

RE: CHAIN Operation results in more than 1 row

(OP)
How does the CHAIN operation behave when there are more than 1 record that meets the key? If there are 2 records that meet the key will the CHAIN just ignore the record and move to the next?

I've encountered this a few times now where the users put in a record with a key that already exists. I usually have to delete the duplicate record then rerun the job.

 

RE: CHAIN Operation results in more than 1 row

Quote (Ju5):


...the users put in a record with a key that already exists. I usually have to delete the duplicate record...
To avoid that the users can write duplicates in the table, you can create unique index on the table - for example:

CODE

CREATE UNIQUE INDEX my_lib/my_lfidx ON my_lib/my_pf
(my_key1 ASC, my_key2 ASC, my_key3 ASC)
 

RE: CHAIN Operation results in more than 1 row

Quote:

How does the CHAIN operation behave when there are more than 1 record that meets the key? If there are 2 records that meet the key will the CHAIN just ignore the record and move to the next?
If you do NOT specify FIFO, FCFO or LIFO no guaranteed order is specified for retrieving records with duplicate keys.
 

Quote:

I've encountered this a few times now where the users put in a record with a key that already exists. I usually have to delete the duplicate record then rerun the job.
You should specify an indicator in positions 71-72 that is set on if no record in the file matches the search argument or use the %FOUND built-in function, which returns '0' if no record is found, and '1' if a record is found. If the indicator is off or FOUND BIF is on then proceed to update the current record otherwise ignore or write the new record.

Philippe

RE: CHAIN Operation results in more than 1 row

Quote:


How does the CHAIN operation behave when there are more than 1 record that meets the key? If there are 2 records that meet the key will the CHAIN just ignore the record and move to the next?

A CHAIN operation does not ignore records. It simply gets one record. As MERCURY2 stated, without specifying LIFO, FIFO, or FCFO, there's no telling which of the duplicate records will be retrieved.

A SETLL and READE combiation is what will read duplicate records. I agree with mikrom. The file should have unique keys if duplicates are not allowed. You can then test for an error message when an attempt is made to add a duplicate.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close