
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : tibero 접속 모듈에 관련된 SQL입니다.
-->
<mapper namespace="tiberoDAO">
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 커넥션된 데이터베이스의 테이블 목록 조회 SQL입니다.
-->
<select id="getDBConnectionTableList" parameterType="ConnectionDB" resultType="Dataset">
SELECT owner AS "databaseNm"
, table_name AS "tableNm"
, comments AS "tableNmKr"
FROM all_tab_comments
WHERE owner = #{userId}
ORDER BY table_name ASC
</select>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 커넥션된 데이터베이스의 테이블의 컬럼 정보 조회 (DB 기준 데이터 타입, 데이터 크기 등)
-->
<select id="getDBConnectionTableColumnList" parameterType="Dataset" resultType="ColumnData">
SELECT
A.OWNER AS "databaseNm",
A.TABLE_NAME AS "tableNm",
A.COLUMN_NAME AS "columnNm",
A.COLUMN_NAME AS "displyColumnNm",
A.COLUMN_NAME AS "orginlColumnNm",
A.DATA_TYPE AS "dbDataType",
A.CHAR_LENGTH AS "dataSize",
A.COLUMN_ID AS "ordr",
MAX(CASE
WHEN P.CONSTRAINT_TYPE = 'P' THEN 'true'
ELSE 'false'
END) AS "pkAt",
MAX(CASE
WHEN U.CONSTRAINT_TYPE = 'U' THEN 'true'
ELSE 'false'
END) AS "uniqeAt"
FROM
ALL_TAB_COLUMNS A
LEFT JOIN ALL_CONS_COLUMNS B ON A.TABLE_NAME = B.TABLE_NAME AND A.COLUMN_NAME = B.COLUMN_NAME AND A.OWNER = B.OWNER
LEFT JOIN ALL_CONSTRAINTS P ON B.OWNER = P.OWNER AND B.CONSTRAINT_NAME = P.CONSTRAINT_NAME AND P.CONSTRAINT_TYPE = 'P'
LEFT JOIN ALL_CONSTRAINTS U ON B.OWNER = U.OWNER AND B.CONSTRAINT_NAME = U.CONSTRAINT_NAME AND U.CONSTRAINT_TYPE = 'U'
WHERE
A.OWNER = #{databaseNm}
AND
A.TABLE_NAME = #{tableNm}
GROUP BY
A.OWNER, A.TABLE_NAME, A.COLUMN_NAME, A.DATA_TYPE, A.CHAR_LENGTH, A.COLUMN_ID
ORDER BY
A.COLUMN_ID
</select>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용: 커넥션된 데이터베이스의 테이블의 데이터 목록 조회 SQL입니다.(페이징)
-->
<select id="getDBConnectionTableDataList" parameterType="DataTable" resultType="java.util.LinkedHashMap">
SELECT
*
FROM (
SELECT
<!-- 정렬 -->
<choose>
<!-- 정렬할 컬럼이 존재할 때 -->
<when test="order != null and order != ''">
ROW_NUMBER() OVER (ORDER BY t."${order}"
<choose>
<!-- 오름차순일 때 -->
<when test="isOrderASC == true">
ASC
</when>
<!-- //오름차순일 때 -->
<!-- 내림차순일 때 -->
<otherwise>
DESC
</otherwise>
<!-- 내림차순일 때 -->
</choose>
) AS rownum,
</when>
<!-- //정렬할 컬럼이 존재할 때 -->
</choose>
<!-- 정렬 -->
t.*
FROM
"${databaseNm}"."${tableNm}" t
WHERE 1 = 1
<!-- 검색 -->
<choose>
<!-- 컬럼 데이터 목록이 존재하고, 검색 조건이 없고, 검색 키워드가 있을 때 -->
<when test="columnDatas != null and columnDatas.size() > 0 and (searchCondition == null or searchCondition == '') and searchKeyword != null and searchKeyword != ''">
AND
<foreach item="item" index="index" collection="columnDatas" open="(" separator=" OR " close=")">
<foreach item="keyword" index="index2" collection="searchKeywordList" separator=" OR ">
t."${item.columnNm}" LIKE '%' || #{keyword} || '%'
</foreach>
</foreach>
</when>
<!-- //컬럼 데이터 목록이 존재하고, 검색 조건이 없고, 검색 키워드가 있을 때 -->
<!-- 컬럼 데이터 목록이 존재하지 않거나, 검색 조건이 있거나, 검색 키워드가 있을 때 -->
<otherwise>
<if test="searchCondition != null and searchCondition != '' and searchKeyword != null and searchKeyword != ''">
AND
<foreach item="keyword" index="index2" collection="searchKeywordList" open="(" separator=" OR " close=")">
t."${searchCondition}" LIKE '%' || #{keyword} || '%'
</foreach>
</if>
</otherwise>
<!-- //컬럼 데이터 목록이 존재하지 않거나, 검색 조건이 있거나, 검색 키워드가 있을 때 -->
</choose>
<!-- //검색 -->
)
<if test="isUsePaging == true">
WHERE rownum BETWEEN #{startIndex} + 1 AND #{startIndex} + #{perPage}
</if>
</select>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용: 커넥션된 데이터베이스의 테이블의 데이터 목록 총 갯수 조회 SQL입니다.
-->
<select id="getDBConnectionTableDataTotalRows" parameterType="DataTable" resultType="java.lang.Integer">
SELECT
COUNT(0)
FROM
"${tableNm}" t
WHERE 1 = 1
<!-- 검색 -->
<choose>
<!-- 컬럼 데이터 목록이 존재하고, 검색 조건이 없고, 검색 키워드가 있을 때 -->
<when test="columnDatas != null and columnDatas.size() > 0 and (searchCondition == null or searchCondition == '') and searchKeyword != null and searchKeyword != ''">
AND
<foreach item="item" index="index" collection="columnDatas" open="(" separator=" OR " close=")">
<foreach item="keyword" index="index2" collection="searchKeywordList" separator=" OR ">
t."${item.columnNm}" LIKE '%' || #{keyword} || '%'
</foreach>
</foreach>
</when>
<!-- //컬럼 데이터 목록이 존재하고, 검색 조건이 없고, 검색 키워드가 있을 때 -->
<!-- 컬럼 데이터 목록이 존재하지 않거나, 검색 조건이 있거나, 검색 키워드가 있을 때 -->
<otherwise>
<if test="searchCondition != null and searchCondition != '' and searchKeyword != null and searchKeyword != ''">
AND
<foreach item="keyword" index="index2" collection="searchKeywordList" open="(" separator=" OR " close=")">
t."${searchCondition}" LIKE '%' || #{keyword} || '%'
</foreach>
</if>
</otherwise>
<!-- //컬럼 데이터 목록이 존재하지 않거나, 검색 조건이 있거나, 검색 키워드가 있을 때 -->
</choose>
<!-- //검색 -->
</select>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용: 커스텀 테이블 데이터 조회 (페이징사용 유무에 따라 페이징 처리) SQL입니다.
-->
<select id="getDBConnectionCustomQueryDataList" parameterType="DataTable" resultType="java.util.LinkedHashMap">
SELECT
a.*
FROM (
${query}
) a
<if test="limit > 0">
WHERE ROWNUM <![CDATA[<=]]> #{limit}
</if>
</select>
<!--
작성자: 최정우
작성일: 2020.01.27
내용: 커스텀 테이블 실행형
-->
<update id="executeCustomQuery" parameterType="DataTable">
/*+ RULE */
${query}
</update>
<!--
작성자: 최정우
작성일: 2020.01.27
내용: 커스텀 테이블 데이터 목록 총 갯수 조회 SQL입니다.
-->
<select id="getDBConnectionCustomQueryDataTotalRows" parameterType="DataTable" resultType="java.lang.Integer">
SELECT
COUNT(0)
FROM (
${query}
) a
</select>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용: DB연계 데이터 목록 조회 (초기 DB화 때에 등록한 컬럼만 가지고 옴)
-->
<select id="getDBCollectionQueryDataList" parameterType="DataTable" resultType="java.util.LinkedHashMap">
SELECT
<foreach item="item" index="index" collection="columnDatas" open="" separator="," close="">
a."${item.orginlColumnNm}" AS "${item.columnNm}"
</foreach>
FROM (
SELECT
<!-- 정렬 -->
<choose>
<!-- 정렬할 컬럼이 존재할 때 -->
<when test="order != null and order != ''">
ROW_NUMBER() OVER (ORDER BY t."${order}"
<choose>
<!-- 오름차순일 때 -->
<when test="isOrderASC == true">
ASC
</when>
<!-- //오름차순일 때 -->
<!-- 내림차순일 때 -->
<otherwise>
DESC
</otherwise>
<!-- 내림차순일 때 -->
</choose>
) AS rownum
</when>
<!-- //정렬할 컬럼이 존재할 때 -->
</choose>
<!-- 정렬 -->
, t.*
FROM (
${query}
) t
WHERE 1 = 1
<!-- 검색 -->
<choose>
<!-- 컬럼 데이터 목록이 존재하고, 검색 조건이 없고, 검색 키워드가 있을 때 -->
<when test="columnDatas != null and columnDatas.size() > 0 and (searchCondition == null or searchCondition == '') and searchKeyword != null and searchKeyword != ''">
AND
<foreach item="item" index="index" collection="columnDatas" open="(" separator=" OR " close=")">
<foreach item="keyword" index="index2" collection="searchKeywordList" separator=" OR ">
t."${item.orginlColumnNm}" LIKE '%' || #{keyword} || '%'
</foreach>
</foreach>
</when>
<!-- //컬럼 데이터 목록이 존재하고, 검색 조건이 없고, 검색 키워드가 있을 때 -->
<!-- 컬럼 데이터 목록이 존재하지 않거나, 검색 조건이 있거나, 검색 키워드가 있을 때 -->
<otherwise>
<if test="searchCondition != null and searchCondition != '' and searchKeyword != null and searchKeyword != ''">
AND
<foreach item="keyword" index="index2" collection="searchKeywordList" open="(" separator=" OR " close=")">
t."${searchCondition}" LIKE '%' || #{searchKeyword} || '%'
</foreach>
</if>
</otherwise>
<!-- //컬럼 데이터 목록이 존재하지 않거나, 검색 조건이 있거나, 검색 키워드가 있을 때 -->
</choose>
<!-- //검색 -->
) a
<if test="isUsePaging == true">
WHERE rownum BETWEEN #{startIndex} + 1 AND #{startIndex} + #{perPage}
</if>
</select>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용: DB연계 데이터 목록 총 갯수 조회
-->
<select id="getDBCollectionQueryDataTotalRows" parameterType="DataTable" resultType="java.lang.Integer">
SELECT
COUNT(0)
FROM (
${query}
) t
WHERE 1=1
<!-- 검색 -->
<choose>
<!-- 컬럼 데이터 목록이 존재하고, 검색 조건이 없고, 검색 키워드가 있을 때 -->
<when test="columnDatas != null and columnDatas.size() > 0 and (searchCondition == null or searchCondition == '') and searchKeyword != null and searchKeyword != ''">
AND
<foreach item="item" index="index" collection="columnDatas" open="(" separator=" OR " close=")">
<foreach item="keyword" index="index2" collection="searchKeywordList" separator=" OR ">
t."${item.orginlColumnNm}" LIKE '%' || #{keyword} || '%'
</foreach>
</foreach>
</when>
<!-- //컬럼 데이터 목록이 존재하고, 검색 조건이 없고, 검색 키워드가 있을 때 -->
<!-- 컬럼 데이터 목록이 존재하지 않거나, 검색 조건이 있거나, 검색 키워드가 있을 때 -->
<otherwise>
<if test="searchCondition != null and searchCondition != '' and searchKeyword != null and searchKeyword != ''">
AND
<foreach item="keyword" index="index2" collection="searchKeywordList" open="(" separator=" OR " close=")">
t."${searchCondition}" LIKE '%' || #{keyword} || '%'
</foreach>
</if>
</otherwise>
<!-- //컬럼 데이터 목록이 존재하지 않거나, 검색 조건이 있거나, 검색 키워드가 있을 때 -->
</choose>
<!-- //검색 -->
</select>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용: 커스텀 쿼리 지정된 PK의 중복 데이터 수 (지정된 PK로 Table 생성이 가능한지 알아보기 위함)
-->
<select id="getCustomQueryPrimaryOverlapCount" parameterType="DataTable" resultType="java.lang.Integer">
SELECT
NVL(SUM(a.overlapCount), 0) AS totalOverlapCount
FROM (
SELECT
COUNT(0) AS overlapCount
FROM (
${query}
) t
GROUP BY
<foreach item="item" index="index" collection="columnData" open="" separator="," close="">
t."${item.columnNm}"
</foreach>
HAVING
COUNT(0) > 1
) a
</select>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용 : 데이터 셋의 DB화 (테이블 생성) / 오라클에서는 테이블을 만들며 comment 추가 불가능
-->
<update id="datasetTableCreate" parameterType="DataTable">
CREATE TABLE "${tableNm}" (
<foreach item="item" index="index" collection="columnDatas" separator=",">
"${item.columnNm}"
<choose>
<when test="item.dbDataType == 'varchar'">
VARCHAR(${item.dataSize})
</when>
<otherwise>
${item.dbDataType}
</otherwise>
</choose>
<choose>
<when test="item.pkAt == true"> NOT NULL</when>
<otherwise>DEFAULT NULL</otherwise>
</choose>
</foreach>
, PRIMARY KEY (
<foreach item="item" index="index" collection="columnDatas" separator=",">
<if test="item.pkAt == true">
"${item.columnNm}"
</if>
</foreach>
)
<foreach item="item" index="index" collection="columnDatas">
<if test="item.isUniq == true">
, CONSTRAINT "${tableNm}_${item.columnNm}_UNIQUE" UNIQUE ("${item.columnNm}")
</if>
</foreach>
)
</update>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용 : 데이터 셋의 DB화 (테이블 생성) / 오라클에서는 테이블을 만들며 comment 추가 불가능
-->
<update id="datasetDefaultTableCreate" parameterType="DataTable">
CREATE TABLE "${tableNm}" (
"ts_row" NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY
<foreach item="item" index="index" collection="columnDatas">
, "${item.columnNm}"
<choose>
<when test="item.dbDataType == 'double'">
NUMBER
</when>
<when test="item.dbDataType == 'varchar'">
VARCHAR(${item.dataSize})
</when>
<otherwise>
${item.dbDataType}
</otherwise>
</choose>
DEFAULT NULL
</foreach>
<foreach item="item" index="index" collection="columnDatas" separator=",">
<if test="item.isUniq == true">
CONSTRAINT ${tableNm}_${item.columnNm}_UNIQUE UNIQUE (${item.columnNm})
</if>
</foreach>
)
</update>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용 : 데이터 셋의 DB화 (데이터 생성 및 업데이트)
-->
<update id="datasetDataUpdate" parameterType="DataTable">
MERGE INTO "${tableNm}" S
USING (
<foreach item="row" collection="rowData" separator="UNION ALL">
<foreach item="cell" index="index" collection="row" open="SELECT" separator="," close="FROM dual">
#{cell} AS "${columnDatas[index].columnNm}"
</foreach>
</foreach>
) D ON
<foreach item="item" index="index" collection="columnDatas" open="(" separator="," close=")">
<if test="item.pkAt == true">
S."${item.columnNm}" = D."${item.columnNm}"
</if>
</foreach>
WHEN MATCHED THEN
UPDATE SET
<foreach item="item" index="index" collection="columnDatas" separator=",">
<if test="item.pkAt == false">
S."${item.columnNm}" = D."${item.columnNm}"
</if>
</foreach>
WHEN NOT MATCHED THEN
INSERT
<foreach item="item" index="index" collection="columnDatas" open="(" separator="," close=")">
"${item.columnNm}"
</foreach>
VALUES
<foreach item="item" index="index" collection="columnDatas" open="(" separator="," close=")">
D."${item.columnNm}"
</foreach>
</update>
<!--
작성자: 박민혁
작성일 : 2024.04.01
내용 : 데이터 셋의 ROW 삭제
-->
<update id="datasetDataDelete" parameterType="DataTable">
DELETE FROM "${tableNm}"
WHERE
1 = 1
<foreach item="item" index="index" collection="columnDatas" open=" AND " separator=" AND " close="">
"${item.columnNm}" in
<foreach item="items" index="indexs" collection="item.values" open="(" separator=", " close=")">
#{items}
</foreach>
</foreach>
</update>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 중복 테이블명 체크
-->
<select id="duplicateChecktableNm" parameterType="Map" resultType="INTEGER">
SELECT COUNT(*)
FROM
ALL_TABLES
WHERE
OWNER = #{schema}
AND
TABLE_NAME = #{tableNm}
</select>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 데이터 셋의 컬럼 정보 목록 조회 SQL에 접근하는 메소드 입니다.(페이징)
-->
<select id="getRowData" parameterType="DataTable" resultType="java.util.LinkedHashMap">
SELECT
<foreach item="item" index="index" collection="columnDatas" open="" separator="," close="">
"${item.columnNm}"
</foreach>
FROM (
SELECT
<!-- 정렬 -->
<choose>
<when test="order != null and order != ''">
ROW_NUMBER() OVER (ORDER BY t."${order}"
<choose>
<!-- 오름차순일 때 -->
<when test="isOrderASC == true">
ASC
</when>
<!-- //오름차순일 때 -->
<!-- 내림차순일 때 -->
<otherwise>
DESC
</otherwise>
<!-- 내림차순일 때 -->
</choose>
) AS NUM
</when>
<!-- //정렬할 컬럼이 존재할 때 -->
<!-- 정렬할 컬럼이 없을 때 -->
<otherwise>
ROWNUM AS NUM
</otherwise>
</choose>
<!-- 정렬 -->
, t.*
FROM "${tableNm}" t
)
WHERE 1 = 1
<!-- 검색 -->
<if test="searchCondition != null and searchCondition != '' and searchKeyword != null and searchKeyword != ''">
AND
"${searchCondition}" LIKE '%' || #{searchKeyword} || '%'
</if>
<!-- //검색 -->
<if test="isUsePaging == true">
AND NUM BETWEEN #{offset} + 1 AND #{offset} + #{perPage}
</if>
</select>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 데이터 셋의 컬럼 정보 목록 조회 SQL에 접근하는 메소드 입니다.(노페이징)
-->
<select id="getRowDataAll" parameterType="DataTable" resultType="java.util.LinkedHashMap">
<choose>
<when test="query != null and query != ''">
SELECT
<foreach item="item" index="index" collection="columnDatas" open="" separator="," close="">
"${item.columnNm}" ${item.displyColumnNm}
</foreach>
FROM (
SELECT a.*, ROWNUM FROM (
SELECT
<foreach item="item" index="index" collection="columnDatas" open="" separator="," close="">
"${item.columnNm}"
</foreach>
FROM "${tableNm}"
WHERE 1 = 1
${query}
) WHERE ROWNUM > 0
</when>
<otherwise>
SELECT
<foreach item="item" index="index" collection="columnDatas" open="" separator="," close="">
"${item.columnNm}" AS "${item.displyColumnNm}"
</foreach>
FROM
"${tableNm}"
</otherwise>
</choose>
</select>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용: 데이터 셋의 컬럼 정보 목록 총 갯수 조회 SQL
-->
<select id="getRowDataTotalRows" parameterType="DataTable" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
"${tableNm}"
WHERE 1 = 1
<if test="searchCondition != null and searchCondition != '' and searchKeyword != null and searchKeyword != ''">
AND
"${searchCondition}" LIKE '%' || #{searchKeyword} || '%'
</if>
</select>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 데이터 셋의 비우기 (데이터 셋 내용삭제)
-->
<delete id="emptyDataset" parameterType="DataTable">
DELETE FROM "${tableNm}"
</delete>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 실제 생성된 컬럼 변경
-->
<update id="tableColumnChange" parameterType="TableBasicInfo">
<choose>
<when test="process == 'CHANGE'">
ALTER TABLE "${tableName}" RENAME COLUMN "${columnName}" TO "${tobeColumnName}"
</when>
<when test="process == 'MODIFY'">
<choose>
<when test="dataType == 'varchar'">
ALTER TABLE "${tableName}" ${process} "${columnName}" ${dataType} (${size})
</when>
<when test="dataType == 'double'">
ALTER TABLE "${tableName}" ${process} "${columnName}" FLOAT
</when>
<when test="dataType == 'bigint'">
ALTER TABLE "${tableName}" ${process} "${columnName}" NUMBER(19)
</when>
<when test="dataType == 'datetime'">
ALTER TABLE "${tableName}" ${process} "${columnName}" DATE
</when>
<otherwise>
ALTER TABLE "${tableName}" ${process} "${columnName}" ${dataType}
</otherwise>
</choose>
</when>
<when test="process == 'ADD'">
ALTER TABLE "${tableName}" ${process} "${columnName}" ${dataType}
<if test="dataType == 'varchar'">
(${size})
</if>
</when>
<when test="process == 'DROP'">
ALTER TABLE "${tableName}" ${process} COLUMN "${columnName}"
</when>
</choose>
</update>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 실제 생성된 테이블 PK처리
-->
<update id="changePromaryKey" parameterType="TableBasicInfo">
<choose>
<when test="process == 'DROP'">
ALTER TABLE "${tableName}" DROP PRIMARY KEY
</when>
<otherwise>
ALTER TABLE "${tableName}" ADD CONSTRAINT ${tableName}_PK PRIMARY KEY
<foreach item="item" index="index" collection="primaryList" open=" (" separator=", " close=")">
${item}
</foreach>
</otherwise>
</choose>
</update>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : AI PK 생성
-->
<update id="createAutoIncrement" parameterType="TableBasicInfo">
ALTER TABLE "${tableName}" ADD "${columnName}" NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY
PRIMARY KEY
</update>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 테이블 메타정보 변경 (comments)
-->
<update id="updateTableMetaInfo" parameterType="DataTable">
COMMENT ON TABLE ${tableNm} IS #{datasetSj}
</update>
<!--
작성자 : 박민혁
작성일 : 2024.04.01
내용 : 중복 테이블명 체크
-->
<select id="duplicateCheckTableName" parameterType="Map" resultType="Integer">
SELECT count(*)
FROM
ALL_TABLES
WHERE
OWNER = #{userId}
AND
TABLE_NAME = #{tableName}
</select>
</mapper>