Comparing RPG to C# and SQL.

Posted by Kevin on Stack Overflow See other posts from Stack Overflow or by Kevin
Published on 2010-04-13T23:19:19Z Indexed on 2010/04/13 23:23 UTC
Read the original article Hit count: 391

Filed under:
|
|

In an RPG program (One of IBM's languages on the AS/400) I can "chain" out to a file to see if a record (say, a certain customer record) exists in the file. If it does, then I can update that record instantly with new data. If the record doesn't exist, I can write a new record. The code would look like this:

Customer  Chain CustFile   71 ;turn on indicator 71 if not found
          if    *in71         ;if 71 is "on"
          eval  CustID = Customer;
          eval  CustCredit = 10000;
          write CustRecord
          else                ;71 not on, record found.
          CustCredit = 10000;
          update CustRecord
          endif

Not being real familiar with SQL/C#, I'm wondering if there is a way to do a random retrieval from a file (which is what "chain" does in RPG). Basically I want to see if a record exists. If it does, update the record with some new information. If it does not, then I want to write a new record. I'm sure it's possible, but not quite sure how to go about doing it. Any advice would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql