zoukankan      html  css  js  c++  java
  • jpa 表字段转bean对象

    select 'private ' || decode(v_type, 'int', 'Integer', 'float', 'Double', 'date', 'Date', 'String') || ' ' || v_name || ';' from
    (
    select column_id, column_name,
    case when instr(v_name, '_') > 0 then substr(v_name, 1, instr(v_name, '_') - 1) || upper(substr(v_name, instr(v_name, '_') + 1, 1)) || lower(substr(v_name, instr(v_name, '_') + 2)) else v_name end v_name, v_type
    from
    (
    select column_id, column_name, (case length(substr(column_name, 1, instr(column_name, '_') - 1)) when 1 then substr(column_name, 1, 1) else
    lower(substr(column_name, 1, instr(column_name, '_') - 1)) end) || substr(column_name, instr(column_name, '_') + 1, 1) || lower(substr(column_name, instr(column_name, '_') + 2)) v_name,
    (case when data_type = 'NUMBER' and data_scale > 0 then 'float' else (case data_type when 'NUMBER' then 'int' when 'DATE' then 'date' else 'string' end) end) v_type
    from user_tab_columns where table_name = 'MZGL_BRSFMX' --order by column_id
    ) --order by column_id
    ) order by column_id;

    declare
    r_return varchar2(200);
    v_sql varchar2(1000);
    CURSOR C_AGE IS SELECT column_name FROM all_tab_columns where table_name='MZGL_BRSFMX' order by column_id;

    begin
    v_sql:='';
    FOR R_DT IN C_AGE LOOP

    r_return:= (case length(substr(R_DT.column_name, 1, instr(R_DT.column_name, '_') - 1)) when 1 then substr(R_DT.column_name, 1, 1) else
    lower(substr(R_DT.column_name, 1, instr(R_DT.column_name, '_') - 1)) end) || substr(R_DT.column_name, instr(R_DT.column_name, '_') + 1, 1) || lower(substr(R_DT.column_name, instr(R_DT.column_name, '_') + 2)) ;
    --r_return:= R_DT.column_name;
    v_sql:=v_sql||',"'||r_return||'"';
    END LOOP;
    dbms_output.put_line(v_sql);
    end;

  • 相关阅读:
    PHP安全
    使用 jQuery 简化 Ajax 开发
    我的云之旅–HBase调试(139)
    Java的性能调优
    libsqlite3.dylib与libsqlite3.0.dylib区别
    zookeeper code
    最近的一个框架
    我的云之旅–Lucene内容存储进入Hadoop(136)
    Linux源码阅读推荐阅读图书
    我的云之旅–HMaster启动说明(140)
  • 原文地址:https://www.cnblogs.com/doudou618/p/5902564.html
Copyright © 2011-2022 走看看