SELECT nfsphys_id, TRIM (dir) FROM nfsphys
WHERE mach_id = :mach_id
ORDER BY 2 DESC;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr101;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr101 INTO :var_phys_id, :dir;
if(sqlca.sqlcode != 0) break;
name = argv[1];
if (name_to_id(name, "STRING", &id) != MR_SUCCESS) {
if (q->type != APPEND) return(MR_STRING);
- EXEC SQL SELECT value INTO :id FROM numvalues
- WHERE name = 'strings_id';
- id++;
- EXEC SQL UPDATE numvalues SET value = :id
- WHERE name = 'strings_id';
- EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
+ id=add_string(name);
cache_entry(name, "STRING", id);
}
if (ingres_errno) return(mr_errcode);
name = kname_unparse(si.pname, si.pinst, si.prealm);
status = name_to_id(name, "STRING", &sigwho);
if (status == MR_NO_MATCH) {
- EXEC SQL REPEATED SELECT value INTO :sigwho FROM numvalues
- WHERE name='strings_id';
- sigwho++;
- EXEC SQL REPEATED UPDATE numvalues SET value = :sigwho
- WHERE name='strings_id';
- EXEC SQL INSERT INTO strings (string_id, string)
- VALUES (:sigwho, :name);
+ sigwho=add_string(name);
} else if (status)
return(status);
timestamp = si.timestamp;
name = kname_unparse(si.pname, si.pinst, si.prealm);
status = name_to_id(name, "STRING", &sigwho);
if (status == MR_NO_MATCH) {
- EXEC SQL REPEATED SELECT value INTO :sigwho FROM numvalues
- WHERE name='strings_id';
- sigwho++;
- EXEC SQL REPEATED UPDATE numvalues SET value = :sigwho
- WHERE name='strings_id';
- EXEC SQL INSERT INTO strings (string_id, string)
- VALUES (:sigwho, :name);
+ sigwho=add_string(name);
} else if (status)
return(status);
timestamp = si.timestamp;
return(MR_BAD_CHAR);
status = name_to_id(box, "STRING", &id);
if (status == MR_NO_MATCH) {
- EXEC SQL REPEATED SELECT value INTO :id FROM numvalues
- WHERE name='strings_id';
- id++;
- EXEC SQL REPEATED UPDATE numvalues SET value = :id
- WHERE name='strings_id';
- EXEC SQL INSERT INTO strings (string_id, string)
- VALUES (:id, :box);
+ id=add_string(box);
} else if (status)
return(status);
EXEC SQL REPEATED UPDATE users SET potype='SMTP', box_id = :id
optimize_sql_stmt(qual);
EXEC SQL DECLARE csr102 CURSOR FOR SELECT list_id FROM list
WHERE :qual;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr102;
+ if (ingres_errno)
+ return(mr_errcode);
while(1)
{
EXEC SQL FETCH csr102 INTO :id;
EXEC SQL DECLARE csr103 CURSOR FOR
SELECT list_id, ref_count FROM imembers
WHERE member_id = :lid AND member_type='LIST';
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr103;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr103 INTO :id, :ref;
if(sqlca.sqlcode != 0) break;
SELECT member_id, member_type, ref_count
FROM imembers
WHERE list_id = :mid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr104;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr104 INTO :id, :dtype, :ref;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr105 CURSOR FOR
SELECT list_id, ref_count FROM imembers
WHERE member_id = :lid AND member_type = 'LIST';
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr105;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr105 INTO :id, :ref;
if(sqlca.sqlcode!=0) break;
EXEC SQL DECLARE csr106 CURSOR FOR
SELECT member_id, member_type, ref_count FROM imembers
WHERE list_id = :mid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr106;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr106 INTO :id, :dtype, :ref;
if(sqlca.sqlcode!=0) break;
EXEC SQL DECLARE csr107 CURSOR FOR
SELECT list_id FROM imembers
WHERE member_type='LIST' AND member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr107;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr107 INTO :listid;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr108 CURSOR FOR
SELECT list_id FROM imembers
WHERE member_type='USER' AND member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr108;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr108 INTO :listid;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr109 CURSOR FOR
SELECT list_id FROM imembers
WHERE member_type='KERBEROS' AND member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr109;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr109 INTO :listid;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr110 CURSOR FOR
SELECT label FROM filesys
WHERE owners = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr110;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr110 INTO :name;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr111 CURSOR FOR
SELECT capability FROM capacls
WHERE list_id = :aid ;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr111;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr111 INTO :name ;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr112 CURSOR FOR
SELECT label FROM filesys
WHERE owner = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr112;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr112 INTO :name ;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr113 CURSOR FOR
SELECT name FROM list
WHERE acl_type = :atype AND acl_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr113;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr113 INTO :name;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr114 CURSOR FOR
SELECT name FROM servers
WHERE acl_type = :atype AND acl_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr114;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr114 INTO :name;
if(sqlca.sqlcode != 0) break;
SELECT name FROM machine m, hostaccess ha
WHERE m.mach_id = ha.mach_id AND ha.acl_type = :atype
AND ha.acl_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr115;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr115 INTO :name;
if(sqlca.sqlcode != 0) break;
OR z.sub_type = :atype AND z.sub_id = :aid
OR z.iws_type = :atype AND z.iws_id = :aid
OR z.iui_type = :atype AND z.iui_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr116;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr116 INTO :name;
if(sqlca.sqlcode != 0) break;
FROM list l, imembers im
WHERE l.list_id = im.list_id AND im.direct = 1
AND im.member_type = :atype AND im.member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr117a;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr117a
INTO :name, :active, :public, :hidden, :maillist, :grouplist;
FROM list l, imembers im
WHERE l.list_id = im.list_id
AND im.member_type = :atype AND im.member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr117b;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr117b
INTO :name, :active, :public, :hidden, :maillist, :grouplist;
EXEC SQL DECLARE csr118 CURSOR FOR
SELECT member_type, member_id FROM imembers
WHERE list_id = :list_id AND direct > :direct;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr118;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr118 INTO :member_type, :member_id;
if (sqlca.sqlcode != 0) break;
WHERE im.list_id = :list_id AND im.member_type = 'USER'
AND im.member_id = u.users_id AND im.direct > :direct
ORDER BY 1;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr119;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr119 INTO :member_name;
if(sqlca.sqlcode != 0) break;
WHERE im.list_id = :list_id AND im.member_type='LIST'
AND im.member_id = l.list_id AND im.direct > :direct
ORDER BY 1;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr120;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr120 INTO :member_name;
if(sqlca.sqlcode != 0) break;
WHERE im.list_id = :list_id AND im.member_type='STRING'
AND im.member_id = str.string_id AND im.direct > :direct
ORDER BY 1;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr121;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr121 INTO :member_name;
if(sqlca.sqlcode != 0) break;
AND im.member_id = str.string_id
AND im.direct > :direct
ORDER BY 1;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr122;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr122 INTO :member_name;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr124 CURSOR FOR
SELECT sh.service, m.name FROM serverhosts sh, machine m
WHERE :qual;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr124;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr124 INTO :sname, :mname;
if(sqlca.sqlcode != 0) break;
AND sh.value2 - sh.value1 =
(SELECT MAX(value2 - value1) FROM serverhosts
WHERE service = 'POP');
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr130;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL FETCH csr130 INTO :mid, :machname;
if (sqlca.sqlerrd[2] == 0) {
EXEC SQL CLOSE csr130;
return(MR_EXISTS);
} else if (status == MR_NO_MATCH && !strcmp(tbl, "strings") &&
(q->type == APPEND || q->type == UPDATE)) {
- EXEC SQL SELECT value INTO :id FROM numvalues
- WHERE name = 'strings_id';
- id++;
- EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
- EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
+ id=add_string(name);
cache_entry(name, "STRING", id);
*(int *)argv[vo->index] = id;
return(MR_EXISTS);
return(MR_STRING);
if (status == MR_NO_MATCH) {
if (q->type != APPEND && q->type != UPDATE) return(MR_STRING);
- EXEC SQL SELECT value INTO :id FROM numvalues WHERE name = 'strings_id';
- id++;
- EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
- EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
+ id=add_string(name);
cache_entry(name, "STRING", id);
} else if (status) return(status);
} else if (!strcmp(data_type, "none")) {
}
}
+
+
+/* Adds a string to the string table. Returns the id number.
+ *
+ */
+int add_string(name)
+ EXEC SQL BEGIN DECLARE SECTION;
+ char *name;
+ EXEC SQL END DECLARE SECTION;
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ char buf[256];
+ int id;
+ EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL SELECT value INTO :id FROM numvalues WHERE name = 'strings_id';
+ id++;
+ EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
+
+ /* Use sprintf to get around problem with doubled single quotes */
+ sprintf(buf,"INSERT INTO strings (string_id, string) VALUES (%d, '%s')",id,name);
+ EXEC SQL EXECUTE IMMEDIATE :buf;
+
+ return(id);
+}
+
+
/* eof:qsupport.dc */