From 1948b305a01003e3068755f2e7fb9d440c628dde Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 23 Aug 2000 12:32:10 +0000 Subject: [PATCH] *** empty log message *** --- allParam/ora/oraParam.h | 3 ++ allParam/ora/oraParam.pc | 69 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/allParam/ora/oraParam.h b/allParam/ora/oraParam.h index 9b4afe8..ec00b42 100644 --- a/allParam/ora/oraParam.h +++ b/allParam/ora/oraParam.h @@ -5,6 +5,9 @@ * Section containing struct Param (different in the different param.h's) * **************************************************************************/ +#define PARAM_MAX_NAME_LEN 128 +#define PARAM_MAX_NVALS 1024 + typedef struct ParamS { char *strerror; } Param; diff --git a/allParam/ora/oraParam.pc b/allParam/ora/oraParam.pc index 79f0e0d..9b81871 100644 --- a/allParam/ora/oraParam.pc +++ b/allParam/ora/oraParam.pc @@ -31,20 +31,77 @@ int Param_getString(const Param *my, const char *name, const char *idx, int *row int Param_getIntArray(const Param *my, const char *name, const char *idx, int maxrows, int *rows, unsigned long int *val) { + int retVal; int i; - for (i = 0 ; i < maxrows ; i++) { - val[i] = 0; + char *endptr; + EXEC SQL BEGIN DECLARE SECTION; + char value[PARAM_MAX_VALUE_LEN][PARAM_MAX_NVALS]; + char sqlname[PARAM_MAX_NAME_LEN]; + char sqlidx[PARAM_MAX_NAME_LEN]; + EXEC SQL END DECLARE SECTION; + strcpy(sqlname, name); + strcpy(sqlidx, idx); + EXEC SQL WHENEVER SQLERROR DO Param_strerror(my, "Some Oracle error occured.\n"); + EXEC SQL SELECT VALUE INTO :value FROM daq.params WHERE NAME = :sqlname AND IDX = :sqlidx ORDER BY SEQ_NUM; + *rows = sqlca.sqlerrd[2]; + + if (*rows > maxrows) { + Param_strerror(my, "Result has to many rows. Returning only 'maxrows' rows.\n"); + for (i = 0 ; i < maxrows ; i++) { + val[i] = strtoul(value[i], &endptr, NULL); + if(*endptr != '\0') { + Param_strerror(my, "Value seems to be no integer.\n"); + retVal = -1; + } + } + retVal = -1; + } else { + for (i = 0 ; i < *rows ; i++) { + val[i] = strtoul(value[i], &endptr, NULL); + if(*endptr != '\0') { + Param_strerror(my, "Value seems to be no integer.\n"); + retVal = -1; + } + } + for (i = *rows ; i < maxrows ; i++) { + val[i] = 0; + } } - return 0; + retVal = 0; } int Param_getStringArray(const Param *my, const char *name, const char *idx, int maxrows, int *rows, char **val) { + int retVal; int i; - for (i = 0 ; i < maxrows ; i++) { - val[i] = "Blub"; + EXEC SQL BEGIN DECLARE SECTION; + char value[PARAM_MAX_VALUE_LEN][PARAM_MAX_NVALS]; + char sqlname[PARAM_MAX_NAME_LEN]; + char sqlidx[PARAM_MAX_NAME_LEN]; + EXEC SQL END DECLARE SECTION; + strcpy(sqlname, name); + strcpy(sqlidx, idx); + EXEC SQL WHENEVER SQLERROR DO Param_strerror(my, "Some Oracle error occured.\n"); + EXEC SQL SELECT VALUE INTO :value FROM daq.params WHERE NAME = :sqlname AND IDX = :sqlidx ORDER BY SEQ_NUM; + *rows = sqlca.sqlerrd[2]; + + if (*rows > maxrows) { + Param_strerror(my, "Result has to many rows. Returning only 'maxrows' rows.\n"); + for (i = 0 ; i < maxrows ; i++) { + strcpy(val[i], value[i]); + } + retVal = -1; + } else { + for (i = 0 ; i < *rows ; i++) { + strcpy(val[i], value[i]); + } + for (i = *rows ; i < maxrows ; i++) { + val[i] = NULL; + } + retVal = 0; } - return 0; + + return retVal; } const char *Param_getErrStr(const Param *my) -- 2.43.0