create or replace FUNCTION UPDATEEXPERIMENT ( pProtid in results.protid%type, pBCode in batch.bcode%type, pExpCode in RESULTS.EXPCODE%type, pValue in varchar2, pColumn in varchar2 ) RETURN results.expid%type AS cursor getbatch is select batchcode from batch where BCODE=pbcode; pBatchCode BATCH.BATCHCODE%type; pExpId RESULTS.EXPID%type:=-1; cursor getexp(zebcode in BATCH.BATCHCODE%type) is select expid from results where batchcode=zebcode and protid=pprotid and pExpCode=expcode; pSeparator varchar2(1); pAntiSeparator varchar2(1); pTmp results.text1%type; BEGIN open getbatch; fetch getbatch into pBatchCode; if getbatch%found then close getbatch; open getexp(pBatchCode); fetch getexp into pExpId; if getexp%notfound then close getexp; --create experiment pExpId := getrec; insert into RESULTS (expid, protid, batchcode, expcode, status) values (pExpId, pprotid, pBatchCode, pExpCode, 'Y'); else close getexp; end if; --CHECK IF NUMERIC FIELD IF UPPER(SUBSTR(pColumn,1,1))='V' THEN --numeric select substr(value,1,1) into pSeparator from v$nls_parameters where parameter = 'NLS_NUMERIC_CHARACTERS'; if pSeparator = '.' then pAntiSeparator := ','; else pAntiSeparator := '.'; end if; pTmp := replace(pValue, pAntiSeparator, pSeparator); --replace bad with goog in case ELSE pTmp := pvalue; END IF; execute immediate 'update results set ' || pColumn || '=:1 where expid=:2' using pTmp, pExpId; else close getbatch; end if; return pExpId; END UPDATEEXPERIMENT;