본문으로 바로가기
WITH M AS
(
  select TABLE_NAME, COLUMN_NAME, COMMENTS
    from ALL_COL_COMMENTS
   where table_name = 'table_name'
)
SELECT AA.*
     , 'ess.'||AA.CAMELCASE||'   <!-- '||AA.COMMENTS||' -->' as LANG
      , '<th scope="col"><spring:message code=".'||AA.CAMELCASE||'"/><!-- '||AA.COMMENTS||' --></th>' as detaillist
       , ''||AA.COLUMN_NAME||',  /* '||AA.COMMENTS||' */' AS SELECT2_
     , 'A.'||AA.COLUMN_NAME||' as '||AA.CAMELCASE||',  /* '||AA.COMMENTS||' */' AS SELECT_
     , AA.COLUMN_NAME||',   /* '||AA.COMMENTS||' */'    AS INSERT_1
     , '#'||AA.CAMELCASE||'#,   /* '||AA.COMMENTS||' */'  AS INSERT_2
    , AA.COLUMN_NAME||' = #'||AA.CAMELCASE||'#,   /* '||AA.COMMENTS||' */' as UPDATE_
 FROM (
SELECT 'private String '|| LOWER(SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),1,1)) ||SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),2)||'; //'||m.COMMENTS as vo
       ,'private String [] '|| LOWER(SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),1,1)) ||SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),2)||'; //'||m.COMMENTS as voarr
     ,  A.COLUMN_NAME
     , LOWER(SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),1,1)) ||SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),2) AS CAMELCASE
      , 'resultVO.'||LOWER(SUBSTR(REPLACE(INITCAP('SET_'||A.COLUMN_NAME),'_'),1,1)) ||SUBSTR(REPLACE(INITCAP('SET_'||A.COLUMN_NAME),'_'),2)||'(VO.'||LOWER(SUBSTR(REPLACE(INITCAP('GET_'||A.COLUMN_NAME),'_'),1,1)) ||SUBSTR(REPLACE(INITCAP('GET_'||A.COLUMN_NAME),'_'),2)||'()[i]);'  AS set_CAMELCASE
      , 'resultVO.'||LOWER(SUBSTR(REPLACE(INITCAP('SET_'||A.COLUMN_NAME),'_'),1,1)) ||SUBSTR(REPLACE(INITCAP('SET_'||A.COLUMN_NAME),'_'),2)||'('|| LOWER(SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),1,1)) ||SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),2) ||');'  AS set_VOCAMELCASE
     , m.COMMENTS
    ,  '{Header:"'||m.COMMENTS||'",Type:"Text",Width:100,SaveName:"'||LOWER(SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),1,1)) ||SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME),'_'),2)||'",Edit:true,Align:"center"},'  as sheetCol
  FROM ALL_COL_COMMENTS A--USER_TAB_COLUMNS A
          , M
  WHERE A.TABLE_NAME = 'table_name'
    AND A.TABLE_NAME = M.TABLE_NAME
    AND A.COLUMN_NAME = M.COLUMN_NAME
    ) AA

'table_name' 부분만 사용하려는 테이블명으로 변경한 후 사용.

직접 쿼리 날려보고 본인이 사용하고 싶은 방법으로 적용해서 사용. 

직접 칼럼명 다 치지 말고 간편하게 사용하자.

'DB > QUERY' 카테고리의 다른 글

항상 헷갈리는 JOIN  (0) 2024.08.28