Documentation
Getting Started
Installation
Data Grid
Approvals
Administration
Account & Security
Integration & Staging
Architecture
Documentation/Integration & Staging/Database Administration (DBA Reference)

Database Administration (DBA Reference)

When a row is stuck in a locked state due to a pending approval, a database administrator can intervene directly using the queries below. Always prefer the soft-cancel approach in production — it preserves the audit trail.


1. Find all pending (locked) approval requests

SELECT
    ar.Id,
    ar.Status,
    ar.SubmittedAt,
    e.Name         AS Entity,
    u.DisplayName  AS SubmittedBy,
    COUNT(arow.Id) AS LockedRows
FROM ApprovalRequests ar
JOIN Entities e  ON ar.EntityId = e.Id
JOIN Users u     ON ar.SubmittedByUserId = u.Id
LEFT JOIN ApprovalRows arow
    ON arow.ApprovalRequestId = ar.Id AND arow.RowStatus = 'pending'
WHERE ar.Status = 'pending'
GROUP BY ar.Id, ar.Status, ar.SubmittedAt, e.Name, u.DisplayName
ORDER BY ar.SubmittedAt DESC;

2. Inspect the locked rows in a specific request

SELECT
    arow.Id,
    arow.EntityRowId,
    arow.Operation,
    arow.RowStatus,
    arow.RowCode,
    arow.SnapshotData
FROM ApprovalRows arow
WHERE arow.ApprovalRequestId = 123  -- replace with Id from step 1
  AND arow.RowStatus = 'pending';

3a. Soft cancel — recommended for production

Sets the request to cancelled and marks all pending rows as rejected. The row is immediately unlocked on the next grid load. All history is preserved.

UPDATE ApprovalRequests
SET    Status = 'cancelled', ModifiedAt = GETUTCDATE()
WHERE  Id = 123;                   -- replace with the request Id from step 1

UPDATE ApprovalRows
SET    RowStatus = 'rejected'
WHERE  ApprovalRequestId = 123 AND RowStatus = 'pending';

3b. Hard delete — removes all traces

ApprovalRows and ApprovalReviews cascade-delete automatically. Use only for test or demo data cleanup.

DELETE FROM ApprovalRequests WHERE Id = 123;

Impact on records

Soft cancelHard delete
ApprovalRequestsPreserved — Status → cancelledDeleted
ApprovalRows + SnapshotDataPreserved — RowStatus → rejectedCascade deleted
ApprovalReviews (reviewer comments)PreservedCascade deleted
Live entity data (EntityRows)UnchangedUnchanged

Impact on auditing

The AuditLog table is only written when an approval is successfully approved. A pending request that is cancelled or deleted before approval has no AuditLog entry — the changes were never promoted to live data, so there is nothing to audit.

Soft cancelHard delete
AuditLog entriesNone added or removedNone added or removed
Approval history visibleYes — request shows as cancelledNo — all traces removed
Reviewer comments visibleYes — preserved in ApprovalReviewsNo — cascade deleted
After either operation, the locked row is immediately unlocked when the grid reloads. No live entity data is modified by these operations.

Ready to get started?

Start managing your master data with Primentra today.

View Pricing