|
<<SNIP>>
The other procedure calls QCMDEXC to run a QShell function that
returns Active Directory attributes as name-value pairs. I need to
flatten them into rows. I have asked for exactly 7 attributes, not
all are returned for each AD name, and there is a CN= pair, as well
as a blank row between each group.
The only one that doesn't matter to me is the blank row - I use the
CN= as a level-break of sorts. I do have an else here, which really
handles the blank row. I suppose ITERATE could take care of me here.
But I think not - I have a FETCH right after the CASE, within a
WHILE loop, and that would be skipped with an ITERATE.
Putting the CASE in a compound statement - that would work nicely,
too. It fits my structure nicely, I think.
Maybe a hint at the flow will help - some declarations and other
details are omitted
/* Variables */
DECLARE AT_END INT DEFAULT 0;
/* Cursors */
/* Get Active Directory attributes */
DECLARE C1 CURSOR FOR S1;
/* Handlers */
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET AT_END = 1;
/* Global temporary table for LDAP attributes */
DECLARE GLOBAL TEMPORARY TABLE SESSION/LDAPATTRS
(ldapattrs CHAR(100));
/* Pull attributes into temp table */
set sqlStmt = 'select * from qtemp/ldapattrs';
prepare s1 from sqlStmt;
OPEN C1;
FETCH C1 INTO ldaptext;
/* Walk through specialist IDs */
WHILE AT_END = 0 DO
case
-- several WHENs that each set a variable from a name-value pair
-- the variable is used later in an INSERT when a CN= is encountered
else
set at_end = at_end; /* Dummy operation */
end case;
/* Get next ID */
FETCH C1 INTO ldaptext;
END WHILE;
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.