SMALL
await localConnection.execute(
`INSERT INTO dw_synch_backup values(${item.synchSeq},'${item.tableNm}','${item.tableKey1}','${item.tableKey2}',now(),'${item.applyFlag}',${item.applyDate},'${item.checkFlag}',${item.checkDate})`
);
await localConnection.execute(
`DELETE FROM dw_synch where synchSeq = ${item.synchSeq}`
);
많은 양(약 5000~6000개)이상을 반복문을 돌려서 위의 코드를 실행할시에는 모든 양을 작성하기전에 만료된다.
너무 많다고 에러가뜨기때문에 해결법을 찾아보니 prepare라는 것으로 반복문 밖에서 준비를 시켜주라고 한다.
(async () => {
const insertStatement = await localConnection.prepare(
`INSERT INTO dw_synch_backup values(?,?,?,?,now(),?,?,?,?)`
);
const deleteStatement = await localConnection.prepare(
`DELETE FROM dw_synch where synchSeq = ?`
);
while (true) {
const [synchRows] = await localConnection.execute(
'SELECT * FROM dw_synch LIMIT 100'
);
console.log('synchRows.length', synchRows.length);
for (let item of synchRows) {
await callProcedureDX(item.tableNm, item.tableKey1);
await callProcedureDW(item.tableNm, item.tableKey1);
await insertStatement.execute([
item.synchSeq,
item.tableNm,
item.tableKey1,
item.tableKey2,
item.applyFlag,
item.applyDate,
item.checkFlag,
item.checkDate,
]);
await deleteStatement.execute([item.synchSeq]);
}
수정된 코드가 위의 코드이다.
LIST
'일반' 카테고리의 다른 글
20230427 TODO (0) | 2023.04.27 |
---|---|
JavaScript - Promise.all () (0) | 2023.04.27 |
antDesign Datepicker 미래 날짜 선택 못하게 설정 (0) | 2023.04.25 |
useEffect에서 setInterval 사용할시 주의점 (0) | 2023.04.20 |
Nodejs - execute,replace (0) | 2023.04.19 |