Oracle批量生成版本

-- 批量生成版本
DECLARE
  fk_str VARCHAR2(1000) := ‘‘;
BEGIN
  FOR i IN 1001 .. 2000 loop
    fk_str := LOWER(RAWTOHEX(SYS_GUID()));
  
    INSERT INTO kms15.KMS_KNOWLEDGE_BASE_DOC
      SELECT fk_str AS FD_ID,
             2 as FD_KNOWLEDGE_TYPE,
             ‘版本过多测试‘ AS DOC_SUBJECT,
             30 AS DOC_STATUS,
             ‘175fd53f1a478dcf31e168f446c91838‘ AS DOC_CREATOR_ID,
             SYSDATE AS DOC_CREATE_TIME,
             SYSDATE AS DOC_PUBLISH_TIME,
             NULL AS OUTER_AUTHOR,
             NULL AS FD_DESCRIPTION,
             NULL AS DOC_DEPT_ID,
             NULL AS DOC_IS_INTRODUCED,
             0 AS DOC_INTR_COUNT,
             0 AS DOC_EVAL_COUNT,
             NULL AS DOC_SCORE,
             0 AS DOC_READ_COUNT,
             i AS FD_HISTORY_COUNT,
             0 AS FD_TOTAL_COUNT,
             0 AS DOC_IS_NEW_VERSION,
             NULL AUTH_AREA_ID,
             ‘175fd32c4f6108a34d550104da3b0c6d‘ AS DOC_CATEGORY_ID,
             0 AS DOC_DELETE_FLAG,
             NULL AS DOC_DELETE_TIME,
             NULL AS DOC_DELETE_BY,
             ‘175fddeca1aee71e3043d9e4a95aafb8‘ AS DOC_ORIGIN_DOCID,
             0 AS AUTH_READER_FLAG,
             0 AS AUTH_ATT_NODOWNLOAD,
             0 AS AUTH_ATT_NOCOPY,
             0 AS AUTH_ATT_NOPRINT,
             NULL AS FD_SET_TOP_TIME,
             0 AS DOC_IS_INDEX_TOP,
             NULL AS FD_SET_TOP_LEVEL,
             NULL AS FD_SET_TOP_REASON,
             NULL AS FD_TOP_CATEGORY_ID,
             NULL AS DOC_EFFECTIVE_TIME,
             NULL AS DOC_FAILURE_TIME,
             NULL AS DOC_EXPIRE_TIME,
             0 AS FD_CHANGE_READER_FLAG,
             0 AS FD_CHANGE_EDITOR_FLAG,
             0 AS FD_CHANGE_ATT
        FROM kms15.KMS_KNOWLEDGE_BASE_DOC
       WHERE FD_ID = ‘175fd66819242b18446fd804d04bf214‘;
  
    INSERT INTO kms15.KMS_WIKI_MAIN
      SELECT fk_str AS FD_FK_ID,
             DOC_CONTENT,
             FD_HTML_CONTENT,
             FD_CONTENT_TYPE,
             i / 10 AS FD_VERSION,
             ‘175fd613cc203467d49dae141559ada3‘ AS FD_FIRST_ID,
             (SELECT FD_FK_ID
                FROM (SELECT FD_FK_ID, FD_LAST_MODIFIED_TIME
                        FROM kms15.KMS_WIKI_MAIN
                       ORDER BY ROWNUM DESC)
               WHERE ROWNUM <= 1) AS FD_PARENT_ID,
             2 AS FD_LAST_EDITION,
             ‘175fd53f1a478dcf31e168f446c91838‘ AS DOC_ALTEROR_ID,
             SYSDATE AS DOC_ALTER_TIME,
             i AS FD_REASON,
             SYSDATE AS FD_LAST_MODIFIED_TIME,
             NULL AS DOC_RECOMMEND_TIME,
             i AS FD_NUMBER,
             NULL AS EXTEND_FILE_PATH,
             ‘<?xml version="1.0" encoding="UTF-8"?><java version="1.7.0_79" class="java.beans.XMLDecoder"><object class="java.util.HashMap"/></java>‘ AS EXTEND_DATA_XML,
             NULL AS FD_TEMPLATE_ID,
             NULL AS DOC_SOURCE_ID
        FROM kms15.KMS_WIKI_MAIN
       WHERE FD_FK_ID = ‘175fd613cc203467d49dae141559ada3‘;
  
  END loop;
END;

Oracle批量生成版本

上一篇:SQL语句的多表查询方式


下一篇:MySQL 卡死的问题