/*** Copyright (c), The Regents of the University of California *** *** For more information please refer to files in the COPYRIGHT directory ***/ /* These routines provide the generalInsert and Delete row capabilities. Admins (for now) are allowed to call these functions to add or remove specified rows into certain tables. The arguments are similar to the generalQuery in that columns are specified via the COL_ #defines. Currently, updates can only be done on a single table at a time. Initially, this was developed for use with a notification service which was postponed and now may be used with rule tables. */ #include "rodsGeneralUpdate.h" #include "rodsClient.h" #include "icatMidLevelRoutines.h" #include "icatLowLevel.h" extern int sGetColumnInfo(int defineVal, char **tableName, char **columnName); extern icatSessionStruct *chlGetRcs(); extern int icatGeneralQuerySetup(); int updateDebug=0; int logSQLGenUpdate=0; char tSQL[MAX_SQL_SIZE]; int generalInsert(generalUpdateInp_t generalUpdateInp) { int i, j; char *tableName, *columnName; char *firstTableName; char nextSeqValueIndex=-1; static char nextStr[MAX_NAME_LEN]; int doBind; static char myTime[50]; rstrcpy(tSQL, "insert into ", MAX_SQL_SIZE); for (i=0;irowCount=0; */ if (firstCall) { icatGeneralQuerySetup(); } if (generalUpdateInp.type == GENERAL_UPDATE_INSERT) { status = generalInsert(generalUpdateInp); if (status) return (status); /* Since the sql string is lower case, this is not checked for in ICAT test suite; removed since now this is only for extented tables and so would be difficult to test */ if (logSQLGenUpdate) rodsLog(LOG_SQL, "chlGeneralUpdate sql 1"); } else { if (generalUpdateInp.type == GENERAL_UPDATE_DELETE) { status = generalDelete(generalUpdateInp); if (status) return (status); if (logSQLGenUpdate) rodsLog(LOG_SQL, "chlGeneralUpdate sql 2"); } else { return(CAT_INVALID_ARGUMENT); } } status = cmlExecuteNoAnswerSql(tSQL, icss); if (status != 0) { int status2; rodsLog(LOG_NOTICE, "chlGeneralUpdate cmlExecuteNoAnswerSql insert failure %d", status); status2 = cmlExecuteNoAnswerSql("rollback", icss); return(status); } status = cmlExecuteNoAnswerSql("commit", icss); if (status != 0) { rodsLog(LOG_NOTICE, "chlGeneralUpdate cmlExecuteNoAnswerSql commit failure %d", status); return(status); } return(0); } int chlDebugGenUpdate(int mode) { logSQLGenUpdate = mode; return(0); }