- EXEC SQL CLOSE x;
-
- EXEC SQL DECLARE y CURSOR FOR SELECT
- u.clearid, s.string
- FROM users u, strings s
- WHERE u.status != 3 and u.potype='SMTP' and u.box_id = s.string_id;
- EXEC SQL OPEN y;
- while (1) {
- EXEC SQL FETCH y INTO :id, :string;
- if (sqlca.sqlcode != 0) break;
- strtrim(string);
- strtrim(id);
- if (isdigit(id[0])) {
- if ((i = strlen(string)) > 7 &&
- !strcasecmp(".local", string + i - 6)) {
- string[i-6] = 0;
- fprintf(out, "%s %s.mit.edu\n", id, string);
- } else if ( !strchr(string, '@') ) {
- fprintf(out, "%s %s@mit.edu\n", id, string);
- } else
- fprintf(out, "%s %s\n", id, string);
- }
+ /* The following is declarative, not executed,
+ * and so is dependent on where it is in the file,
+ * not in the order of execution of statements.
+ */
+ EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
+
+ EXEC SQL DECLARE x CURSOR FOR SELECT
+ clearid, login
+ FROM users WHERE status != 3 AND potype != 'NONE';
+ EXEC SQL OPEN x;
+ while (1)
+ {
+ EXEC SQL FETCH x INTO :id, :login;
+ if (sqlca.sqlcode)
+ break;
+ strtrim(login);
+ strtrim(id);
+ if (isdigit(id[0]))
+ fprintf(out, "%s %s@MIT.EDU\n", id, login);