当我们在后台给EAS的表大批量插入数据时多用于oracle的大批量insert/merga,FID插入的值不符合EAS表的标准,前台界面上打开单据会报错。这时候就需要调用EAS系统自动获取FID newbosid('bostypeid')
的函数
可以使用SELECT newbosid('B8C37E5B') FROM dual;
直接获取。
bostypeid
为eas\deployed_metas
目录下面的facade_pkmapping.properties
里面的值,自己找下即可。
这里用了merge插入大量数据,大概是10w级别的,需要6~10秒。
merge into t_scm_pricepolicyentry t
USING (SELECT * FROM CT_BD_TMP_POLICYPRICE3 )x
ON (t.fparentid=x.ppid AND t.fmaterialid=x.materialid AND t.fcustomerid=x.customerid)
when matched then update set t.fprice=(x.saleprice*x.customerdiscount)+x.addprice
when not matched then insert (fid, fpricetypeid, feffectivedate, fexpiredate, fmaterialid, fcurrencyid,fremark,
fcheckedstatus, fparentid, fpricesource,fprice)
VALUES
(newbosid('5EBDEF05'), 'j/kAAABmOOlqYc6N', SYSDATE, to_date('2099-12-31','yyyy-MM-dd'), x.materialid, 'dfd38d11-00fd-1000-e000-1ebdc0a8100dDEB58FDC','备注',
3, x.ppid, '000',to_number(x.saleprice*x.customerdiscount)+x.addprice )
;
其实这里更多的是一堆运算,不了解也没关系,我也没完全了解。学习一下高级function也可以。
CREATE OR REPLACE FUNCTION NEWBOSID(TYPESTRING VARCHAR2) RETURN VARCHAR2 IS
GUID RAW(32);
S_GUID VARCHAR2(32);
G_HEX VARCHAR(22);
BEGIN
GUID := SYS_GUID();
S_GUID := RAWTOHEX(GUID);
G_HEX := '0123456789ABCDEFabcdef';
IF LENGTH(TYPESTRING) = 8 THEN
FOR I IN 1 .. 8 LOOP
IF INSTR(G_HEX, SUBSTR(TYPESTRING, I, 1), 1, 1) = 0 THEN
GOTO OLD_FORM;
END IF;
END LOOP;
RETURN UTL_RAW.CAST_TO_VARCHAR2(UTL_ENCODE.BASE64_ENCODE(UTL_RAW.CONCAT(GUID,
HEXTORAW(TYPESTRING))));
ELSIF LENGTH(TYPESTRING) = 4 THEN
GOTO OLD_FORM;
ELSE
RETURN NULL;
END IF;
<>
RETURN SUBSTR(S_GUID, 0, 8) || '-' || SUBSTR(S_GUID, 8, 4) || '-' || SUBSTR(S_GUID,12,4) || '-' || SUBSTR(S_GUID,16,4) || '-' || SUBSTR(S_GUID,20,12) || TYPESTRING;
END;