Function SET189A

LANSA

Function SET189A
********** COMMENT(=======================================================);
********** COMMENT(Process ........: SET_189);
********** COMMENT(Function .......: SET189A);
********** COMMENT(Created on .....: 22/09/00 at 14:43:32);
********** COMMENT(Description ....: SELECT_SQL - Distinct);
********** COMMENT(Version.........: 1);
**********;
********** COMMENT(Full Description: The purpose of this function is to);
********** COMMENT(demonstrate the DISTINCT option in SQL,);
********** COMMENT(when used in a LANSA SELECT_SQL statement);
**********;
********** COMMENT(Note: To use variables in SELECT_SQL statements see);
********** COMMENT(example SET_010.);
**********;
********** COMMENT(Disclaimer: The following material is supplied as);
********** COMMENT(sample material only. No warranty concerning the);
********** COMMENT(material or its use in any way whatsoever is);
********** COMMENT(expressed or implied.);
**********;
********** COMMENT(Minimum LANSA release: 8.0);
**********;
********** COMMENT(=======================================================);
********** COMMENT(Function control options);
FUNCTION OPTIONS(*DIRECT);
**********;
OPEN USE_OPTION(*ONDEMAND);
********** COMMENT(Group and field definitions);
**********;
DEF_LIST NAME(#S_LSTPSL) FIELDS(#S_189NDIS #S_189DIS);
DEFINE FIELD(#S_189TXT1) TYPE(*CHAR) LENGTH(79) INPUT_ATR(LC);
DEFINE FIELD(#S_189TXT2) TYPE(*CHAR) LENGTH(79) INPUT_ATR(LC);
DEFINE FIELD(#S_189TXT3) TYPE(*CHAR) LENGTH(79) INPUT_ATR(LC);
DEFINE FIELD(#S_189NDIS) REFFLD(#EMPNO) COLHDG('Employee number' 'Not Distinct');
DEFINE FIELD(#S_189DIS) REFFLD(#EMPNO) COLHDG('Employee Number' 'Distinct');
DEFINE FIELD(#S_189CNT) TYPE(*DEC) LENGTH(5) DECIMALS(0) DESC('List entry counter');
**********;
**********;
CHANGE FIELD(#S_189TXT1) TO('''This function uses SELECT_SQL from PSLSKL.''');
**********;
BEGIN_LOOP;
EXECUTE SUBROUTINE(NOTDISTINC);
EXECUTE SUBROUTINE(DISTINCT);
DISPLAY FIELDS(#S_189TXT1 #S_189TXT2 #S_189TXT3) DESIGN(*DOWN) IDENTIFY(*NOID) BROWSELIST(#S_LSTPSL);
**********;
END_LOOP;
SUBROUTINE NAME(NOTDISTINC);
CLR_LIST NAMED(#S_LSTPSL);
CHANGE FIELD(#S_189DIS) TO(*NULL);
SELECT_SQL FIELDS(#EMPNO) FROM_FILES((PSLSKL));
CHANGE FIELD(#S_189NDIS) TO(#EMPNO);
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ENDROUTINE;
SUBROUTINE NAME(DISTINCT);
CHANGE FIELD(#S_189CNT) TO(1);
SELECT_SQL FIELDS(#EMPNO) FROM_FILES((PSLSKL)) DISTINCT(*YES);
**********;
GET_ENTRY NUMBER(#S_189CNT) FROM_LIST(#S_LSTPSL);
CHANGE FIELD(#S_189DIS) TO(#EMPNO);
UPD_ENTRY IN_LIST(#S_LSTPSL);
CHANGE FIELD(#S_189CNT) TO('#S_189CNT + 1');
**********;
ENDSELECT;
ENDROUTINE;