상세 컨텐츠

본문 제목

Oracle DTO 만들기

카테고리 없음

by 겸둥선짱 2023. 5. 4. 16:48

본문

SELECT '@Schema(description = "'
              ||REPLACE(b.comments, CHR(10), '')
              ||'")'||CHR(10)
              || 'private '
              || DECODE( a.data_type, 'NUMBER'
                      , 'int '
                      , 'String ' )
              || SUBSTR( lower( a.column_name ), 1, 1 )
              ||SUBSTR( REPLACE( INITCAP( a.column_name ), '_', '' ), 2 )
              ||';'
  FROM user_tab_cols a
     , user_col_comments b
 WHERE a.table_name  = b.table_name
   AND a.column_name = b.column_name
   AND a.table_name  = UPPER( :TABLENAME );

앞의 데이터 타입이나 형태는 각자 맞춰 하면 된다.