已经知道表名,根据表名得到列名,根据列名的类型插入对应的数据。
    
   求存储过程,语句为INSERT   
   
    规则:  INT 为0 
           VARCHARE2 为 “”
           NUMBER   为0.00

解决方案 »

  1.   

       做拼装, insert  into 表名(根据已经知道的表名得到列名)   values(根据列名的类型插入相对应的数据值)  
      

  2.   

    --之前写过一个,对应要求自己改吧。
    --根据表内(OF开头的表)字段类型,如果为日期型,则对系统时间进往前3年内随机减值,
    --如果为NUMBER型,则生产指定范围的随机数
    --字符型字段,因只有一个字段,直接从字典表OD开头的表内读取
    --总计循环指定次数,12次
    --注:只做了打印输出,未真正执行。去掉程序体内的注释部分,可直接执行。
    DECLARE
      lower      INT := 90;
      uper       INT := 120;
      maxLoop int := 12;
      
      strSql     VARCHAR2(32767);
      randDate   VARCHAR2(20):='';
      formatDate VARCHAR2(20):='';
      scaleLen   INT         := 0;
    BEGIN
      FOR i IN 1..maxLoop
      LOOP
        randDate    := sysdate - TRUNC(dbms_random.value(365,3*365),0);
        formatDate  := SUBSTR(randDate,1,4) || 'Y' || SUBSTR(randDate,6,2) || 'M' || SUBSTR(randDate,9,2) || 'D';
        strSql      := '';
        FOR colList IN
        (SELECT * FROM col WHERE tname = 'OF_GW_JB'
        )
        LOOP
          IF (colList.coltype = 'NUMBER') THEN
            --dbms_output.put_line('trunc(dbms_random.value(' || lower || ',' || uper || '),' || scaleLen || '),');
            strSql := strSql || 'trunc(dbms_random.value(' || lower || ',' || uper || '),' || scaleLen || '),';
          END IF;
        END LOOP;
        strSql := 'insert into OF_GW_JB select village_name,' || strSql || '''' || randDate || ''',''' || randDate || ''',''' || formatDate || ''' from od_org_regi';
        dbms_output.put_line(strSql);
        --EXECUTE IMMEDIATE strSql ;
        --commit;
      END LOOP;
    END;