> For the complete documentation index, see [llms.txt](https://developers.fingerpush.com/assemble/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.fingerpush.com/assemble/guide/db.md).

# DB 불러오기 기능 이용

## 데이터 입력

Assemble은 데이터 처리의 편의를 위해 대상자 등록 처리를 파일 업로드 이외에 DB에 대상자를 미리 셋팅 후 불러오기로 셋팅 할 수 있도록 지원합니다. 단, 해당 DB 테이블에 넣는 형식은 테스트로 발송하는 테스트 대상 처리와 동일한 헤더 값을 갖도록 작업이 선행되어야 합니다.

* DB 불러오기 데이터는 사용자 화면에서 입력할 수 없습니다. (DB에 직접 insert)
* Mst 테이블의 gidx는 sendlist의 gidx로 해당하는 데이터는 동일한 gidx로 입력
* Sendlist의 첫 행은 치환될 헤더 내용(치환 필드 이름)을 입력
* 입력 정보가 없는 텍스트 필드는 null 또는 ‘’ 처리

{% code title="Insert 문" %}

```sql
▶ MYSQL
-	DB불러오기 Master 테이블에 데이터 Insert
INSERT INTO com_tgcrm_mst_v2 (gidx, beused, gname, gcount, create_date)
VALUES (그룹번호, 'D', 해당 마스터 이름, 0, now());

-	DB불러오기 Sendlist 테이블에 데이터 Insert
(헤더 값 입력)
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05,
chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10)
VALUES (그룹번호, 치환헤더값1, 치환헤더값2, 치환헤더값3, 치환헤더값4, 치환헤더값5,
치환헤더값6, 치환헤더값7, 치환헤더값8, 치환헤더값9, 치환헤더값10);

(데이터 값 입력)
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05,
chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10)
VALUES (그룹번호, 치환값1, 치환값2, 치환값3, 치환값4, 치환값5, 치환값6, 치환값7,
치환값8, 치환값9, 치환값10)

** 데이터 첫 row는 치환 헤더 값 입력
** 발송 대상 수만큼 insert

-	DB불러오기Master 테이블에 해당하는 정보 update
UPDATE com_tgcrm_mst_v2 SET beused = 'E',
gcount = ((SELECT COUNT(idx) FROM com_tgcrm_sendlist_v2 WHERE gidx = 그룹번호) - 1)
WHERE gidx = 그룹번호;
```

{% endcode %}

{% code title="Insert Sample" %}

```sql
/* Master 데이터 입력 */
/* mysql */
INSERT INTO com_tgcrm_mst_v2 (gidx, beused, gname, gcount, create_date) VALUES (1, 'D', '해당 마스터 이름', 0, now());
/* oracle */
INSERT INTO com_tgcrm_mst_v2 (gidx, beused, gname, gcount, create_date) VALUES (1, 'D', '해당 마스터 이름', 0, SYSDATE);
/* mssql */
INSERT INTO com_tgcrm_mst_v2 (gidx, beused, gname, gcount, create_date) VALUES (1, 'D', '해당 마스터 이름', 0, GETDATE());

/* Sendlist 데이터 입력 */
/* 첫 행은 테스트 파일의 첫 행과 동일한 값을 입력 (치환 헤더 데이터 입력) */
/* mysql, mssql */
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '수신자 번호', '식별자', '이메일', '이름', '발신번호', '포인트', '개별문구', '기타1', '기타2', '옵션');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify01', 'ghdrlfehd@domain.com', '홍길동1', '01000000000', '11', '개별문구1', '기타1', '기타2', '옵션1');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify02', 'ghdrlfehd@domain.com', '홍길동2', '01000000000', '12', '개별문구2', '기타1', '기타2', '옵션2');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify03', 'ghdrlfehd@domain.com', '홍길동3', '01000000000', '13', '개별문구3', '기타1', '기타2', '옵션3');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify04', 'ghdrlfehd@domain.com', '홍길동4', '01000000000', '14', '개별문구4', '기타1', '기타2', '옵션4');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify05', 'ghdrlfehd@domain.com', '홍길동5', '01000000000', '15', '개별문구5', '기타1', '기타2', '옵션5');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify06', 'ghdrlfehd@domain.com', '홍길동6', '01000000000', '16', '개별문구6', '기타1', '기타2', '옵션6');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify07', 'ghdrlfehd@domain.com', '홍길동7', '01000000000', '17', '개별문구7', '기타1', '기타2', '옵션7');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify08', 'ghdrlfehd@domain.com', '홍길동8', '01000000000', '18', '개별문구8', '기타1', '기타2', '옵션8');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify09', 'ghdrlfehd@domain.com', '홍길동9', '01000000000', '19', '개별문구9', '기타1', '기타2', '옵션9');
INSERT INTO com_tgcrm_sendlist_v2 (gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (1, '01000000000', 'identify10', 'ghdrlfehd@domain.com', '홍길동10', '01000000000', '20', '개별문구10', '기타1', '기타2', '옵션10');

/* oracle */
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '수신자 번호', '식별자', '이메일', '이름', '발신번호', '포인트', '개별문구', '기타1', '기타2', '옵션');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify01', 'ghdrlfehd@domain.com', '홍길동1', '01000000000', '11', '개별문구1', '기타1', '기타2', '옵션1');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify02', 'ghdrlfehd@domain.com', '홍길동2', '01000000000', '12', '개별문구2', '기타1', '기타2', '옵션2');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify03', 'ghdrlfehd@domain.com', '홍길동3', '01000000000', '13', '개별문구3', '기타1', '기타2', '옵션3');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify04', 'ghdrlfehd@domain.com', '홍길동4', '01000000000', '14', '개별문구4', '기타1', '기타2', '옵션4');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify05', 'ghdrlfehd@domain.com', '홍길동5', '01000000000', '15', '개별문구5', '기타1', '기타2', '옵션5');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify06', 'ghdrlfehd@domain.com', '홍길동6', '01000000000', '16', '개별문구6', '기타1', '기타2', '옵션6');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify07', 'ghdrlfehd@domain.com', '홍길동7', '01000000000', '17', '개별문구7', '기타1', '기타2', '옵션7');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify08', 'ghdrlfehd@domain.com', '홍길동8', '01000000000', '18', '개별문구8', '기타1', '기타2', '옵션8');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify09', 'ghdrlfehd@domain.com', '홍길동9', '01000000000', '19', '개별문구9', '기타1', '기타2', '옵션9');
INSERT INTO com_tgcrm_sendlist_v2 (idx, gidx, chgtxt01, chgtxt02, chgtxt03, chgtxt04, chgtxt05, chgtxt06, chgtxt07, chgtxt08, chgtxt09, chgtxt10) VALUES (seq_tgcrm_sendlist.NEXTVAL, 1, '01000000000', 'identify10', 'ghdrlfehd@domain.com', '홍길동10', '01000000000', '20', '개별문구10', '기타1', '기타2', '옵션10');


/* Master 데이터 업데이트 */
/* gcount 값은 insert된 sendlist 갯수 - 1 (헤더 데이터 뺀 갯수) 입력 */
UPDATE com_tgcrm_mst_v2 ctm SET ctm.beused = 'E', ctm.gcount = ((SELECT COUNT(idx) FROM com_tgcrm_sendlist_v2 WHERE gidx = 1) - 1) WHERE ctm.gidx = 1;
/* mssql */
UPDATE com_tgcrm_mst_v2 SET beused = 'E', gcount = ((SELECT COUNT(idx) FROM com_tgcrm_sendlist_v2 WHERE gidx = 1) - 1) WHERE gidx = 1;
```

{% endcode %}

## DB 불러오기 테이블 목록

<table><thead><tr><th width="240">Table Name</th><th>Description</th><th data-hidden></th></tr></thead><tbody><tr><td>com_tgcrm<em>_</em>mst (_v2)</td><td>DB 불러오기 그룹 정보가 저장되는 테이블</td><td></td></tr><tr><td>com_tgcrm_sendlist (_v2)</td><td>DB 불러오기 mst에 해당하는 대상 데이터가 저장되는 테이블 </td><td></td></tr></tbody></table>

* com\_tgcrm\_mst (\_v2) 테이블&#x20;

<table><thead><tr><th width="172">Column Name</th><th width="151">Type</th><th width="92">Initial Column</th><th>Description</th></tr></thead><tbody><tr><td>gidx</td><td>INT(11)</td><td>Y</td><td>그룹번호 (PK)</td></tr><tr><td>gname</td><td>VARCHAR(200)</td><td>Y</td><td>그룹이름</td></tr><tr><td>gcount</td><td>INT(11)</td><td>Y</td><td>그룹데이터 개수</td></tr><tr><td>create_date</td><td>DATETIME</td><td>Y</td><td>생성일</td></tr><tr><td>beused</td><td>CHAR(1)</td><td></td><td>사용여부 (E: 사용, D: 미사용)</td></tr></tbody></table>

* com\_tgcrm\_sendlist (\_v2) 테이블&#x20;

<table><thead><tr><th width="159">Column Name</th><th width="159">Type</th><th width="98">Initial Column</th><th>Description</th></tr></thead><tbody><tr><td>idx</td><td>BIGINT(20)</td><td>Y</td><td><p>고유번호 (PK, 자동증가 값)</p><p>오라클 idx 시퀀스: seq_tgcrm_sendlist</p></td></tr><tr><td>gidx</td><td>INT(11)</td><td>Y</td><td>그룹번호</td></tr><tr><td>chgtxt01</td><td>VARCHAR(256)</td><td></td><td>치환값1</td></tr><tr><td>chgtxt02</td><td>VARCHAR(256)</td><td></td><td>치환값2</td></tr><tr><td>chgtxt03</td><td>VARCHAR(256)</td><td></td><td>치환값3</td></tr><tr><td>chgtxt04</td><td>VARCHAR(256)</td><td></td><td>치환값4</td></tr><tr><td>chgtxt05</td><td>VARCHAR(256)</td><td></td><td>치환값5</td></tr><tr><td>chgtxt06</td><td>VARCHAR(256)</td><td></td><td>치환값6</td></tr><tr><td>chgtxt07</td><td>VARCHAR(256)</td><td></td><td>치환값7</td></tr><tr><td>chgtxt08</td><td>VARCHAR(256)</td><td></td><td>치환값8</td></tr><tr><td>chgtxt09</td><td>VARCHAR(256)</td><td></td><td>치환값9</td></tr><tr><td>chgtxt10</td><td>VARCHAR(256)</td><td></td><td>치환값10</td></tr><tr><td></td><td></td><td></td><td></td></tr></tbody></table>

## 유의사항

{% hint style="danger" %} <mark style="color:blue;">**DB 불러오기 사용자 화면 이용 시 유의사항**</mark>

* 입력할 첫 행의 치환값1\~4은 예시처럼  고정된 값을 이용해주셔야 합니다. (상단의 Insert Sample 예시 참조)\
  ex) chgtxt01 : '수신자 번호'\
  &#x20;     chgtxt02 : '식별자'\
  &#x20;     chgtxt03 : '이메일'\
  &#x20;     chgtxt04 : '이름'
* 테스트 파일(테스트 발송용 xls, xlxs, txt) 첫 행과 불러올 DB데이터 첫 행이 일치해야 정상 업로드가 가능합니다.\
  ex) 테스트 파일 첫 행: 치환문구/식별자/기타\
  Sendlist 첫 행: idx, gidx, ‘치환문구’, ‘식별자’, ‘기타’, null, null, null, null, null, null, null
* 전체 삭제는 Mst table, Sendlist table truncate 처리합니다.&#x20;
* 이메일 발송은 최대 5개의 치환문구 이용이가능합니다.
* [어드민 콘솔 가이드의 '\[화면 2.4.2\] 푸시 > 메시지 만들기 > 캠페인 발송 - ➋ 발송대상 지정 및 메시지 내용 작성](https://developers.fingerpush.com/assemble/guide/pages/6B50fyc6vZotcEJO0qva#2.4.2-greater-than-greater-than)'을 참조해 주세요.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.fingerpush.com/assemble/guide/db.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
