SELECT
a.id,
a.site,
a.bu_no AS buNo,
a.request_id AS requestId,
a.transaction_id AS transactionId,
a.interface_name AS interfaceName,
a.request_group_id AS requestGroupId,
a.re_document_no AS reDocumentNo,
a.re_document_type AS reDocumentType,
a.order_no AS orderNo,
a.seq_no AS seqNo,
a.status_code AS statusCode,
a.message,
a.source_system AS sourceSystem,
a.target_system AS targetSystem,
a.need_retry_flag AS needRetryFlag,
a.retry_count AS retryCount,
a.max_retry_count AS maxRetryCount,
a.retry_interval AS retryInterval,
a.next_retry_time AS nextRetryTime,
a.last_retry_time AS lastRetryTime,
a.warehouse_id AS warehouseId,
a.created_by AS createdBy,
a.created_date AS createdDate,
b.interface_type AS interfaceType
FROM api_log as a
left join api_Interface as b on a.interface_name = b.interface_name AND a.site = b.site and a.bu_no = b.bu_no
(a.site in (select site from AccessSite where userID = #{userName}) OR a.site = '*'
and a.bu_no in (select bu_no from AccessBu where username = #{userName}) OR a.bu_no = '*')
and a.type ]]> 'Interface'
AND a.interface_name LIKE '%' + #{interfaceName} + '%'
AND a.request_id = #{requestId}
AND a.order_no LIKE '%' + #{orderNo} + '%'
AND b.interface_type LIKE '%' + #{interfaceType} + '%'
AND a.status_code = #{statusCode}
AND a.source_system = #{sourceSystem}
AND a.target_system = #{targetSystem}
AND a.need_retry_flag = #{needRetryFlag}
AND a.warehouse_id = #{warehouseId}
AND a.transaction_id LIKE '%' + #{transactionId} + '%'
AND CONVERT(varchar(10), a.created_date, 23) >= #{startDate}
AND CONVERT(varchar(10), a.created_date, 23) <= #{endDate}
ORDER BY a.created_date DESC
OFFSET #{offset} ROWS
FETCH NEXT #{limit} ROWS ONLY
SELECT COUNT(*)
FROM api_log as a
left join api_Interface as b on a.interface_name = b.interface_name AND a.site = b.site and a.bu_no = b.bu_no
(a.site in (select site from AccessSite where userID = #{userName}) OR a.site = '*'
and a.bu_no in (select bu_no from AccessBu where username = #{userName}) OR a.bu_no = '*')
and a.type ]]> 'Interface'
AND a.interface_name LIKE '%' + #{interfaceName} + '%'
AND a.request_id = #{requestId}
AND a.order_no LIKE '%' + #{orderNo} + '%'
AND b.interface_type LIKE '%' + #{interfaceType} + '%'
AND a.status_code = #{statusCode}
AND a.source_system = #{sourceSystem}
AND a.target_system = #{targetSystem}
AND a.need_retry_flag = #{needRetryFlag}
AND a.warehouse_id = #{warehouseId}
AND a.transaction_id LIKE '%' + #{transactionId} + '%'
AND CONVERT(varchar(10), a.created_date, 23) >= #{startDate}
AND CONVERT(varchar(10), a.created_date, 23) <= #{endDate}
DELETE FROM api_log WHERE id IN
#{id}
SELECT
id,
site,
bu_no AS buNo,
request_id AS requestId,
transaction_id AS transactionId,
interface_name AS interfaceName,
request_group_id AS requestGroupId,
re_document_no AS reDocumentNo,
re_document_type AS reDocumentType,
order_no AS orderNo,
seq_no AS seqNo,
status_code AS statusCode,
message,
request_data AS requestData,
source_system AS sourceSystem,
target_system AS targetSystem,
need_retry_flag AS needRetryFlag,
retry_count AS retryCount,
max_retry_count AS maxRetryCount,
retry_interval AS retryInterval,
next_retry_time AS nextRetryTime,
last_retry_time AS lastRetryTime,
last_response_data AS lastResponseData,
created_by AS createdBy,
created_date AS createdDate
FROM api_log WITH(NOLOCK)
WHERE site = #{site}
AND bu_no = #{buNo}
AND request_id = #{requestId}
AND request_group_id = #{requestGroupId}
and interface_name = #{interfaceName}
UPDATE api_log
SET status_code = #{statusCode},
message = #{message},
last_response_data = #{lastResponseData},
retry_count = #{retryCount},
last_retry_time = GETDATE()
WHERE site = #{site}
AND bu_no = #{buNo}
AND request_id = #{requestId}
AND request_group_id = #{requestGroupId}