Tuesday, January 14, 2014

Simple Row Exists logic

Here is a nice quick way to find if a row exists in peoplecode.

  1. Function hasGenlDedCd(&EMPLOYEE, &COMPANY, &DEDCD) Returns boolean;
  2. Local Record &rec = CreateRecord(Record.GENL_DED_CD);
  3. Local string &exists = "";
  4. &rec.EMPLID.Value = &EMPLOYEE;
  5. &rec.COMPANY.Value = &COMPANY;
  6. &rec.DEDCD.Value = &DEDCD;
  7. SQLExec("select 'x' from %Table(:1) where %keyEqual(:1)", &rec, &exists);
  8. Return All(&exists);
  9. End-Function;

No comments:

Post a Comment