extern char *whoami;
extern FILE *journal;
+#define INGRES_BAD_INT 4111
+#define INGRES_BAD_DATE 4302
+
/*
* ingerr: (supposedly) called when Ingres indicates an error.
* I have not yet been able to get this to work to intercept a
static int ingerr(num)
int *num;
{
- ingres_errno = SMS_INGRES_ERR;
- com_err(whoami, SMS_INGRES_ERR, " code %d\n", ingres_errno);
- return *num;
+ char buf[256];
+
+ switch (*num) {
+ case INGRES_BAD_INT:
+ ingres_errno = SMS_INTEGER;
+ break;
+ case INGRES_BAD_DATE:
+ ingres_errno = SMS_DATE;
+ break;
+ default:
+ ingres_errno = SMS_INGRES_ERR;
+ com_err(whoami, SMS_INGRES_ERR, " code %d\n", *num);
+ sprintf(buf, "Ingres error %d", *num);
+ send_zgram("ingres_error", buf);
+ return (*num);
+ }
+ return (0);
}
int sms_open_database()
## where cqual
## inquire_equel (errorno = "errorno")
- if (errorno != 0) return(SMS_INGRES_ERR);
+ if (errorno == 4111)
+ return(SMS_INTEGER);
+ else if (errorno != 0)
+ return(SMS_INGRES_ERR);
return(SMS_SUCCESS);
##}
}
## inquire_equel (errorno = "errorno")
- if (errorno != 0) return(SMS_INGRES_ERR);
+ if (errorno == INGRES_BAD_INT)
+ return(SMS_INTEGER);
+ else if (errorno != 0)
+ return(SMS_INGRES_ERR);
return(SMS_SUCCESS);
##}
## repeat retrieve (value = v.#value) where v.#name = @name
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
- return(SMS_INGRES_ERR);
+ return(SMS_NO_ID);
## retrieve (exists = any(tbl.name where tbl.name = value))
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
- return(SMS_INGRES_ERR);
+ return(SMS_NO_ID);
while (exists) {
value++;
+ if (value > MAX_ID_VALUE)
+ value = MIN_ID_VALUE;
## retrieve (exists = any(tbl.name where tbl.name = value))
}