Tuesday, January 14, 2014

Simple Row Exists logic

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

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

No comments:

Post a Comment