存储的 SQL 程序

BarTender System Database 的维护支持以下存储的程序。

SpDeleteOlderRecords

SpDeleteOlderRecords 程序会移除晚于指定时间的数据库记录。它采用以下参数:

常数

描述

BTMS

BarTender 消息

BTLI

BarTender 已打印项目图像

BTLD

BarTender 项目数据库

BTPJ

BarTender 打印作业

BTFB

BarTender 文档 BLOB

BTFM

BarTender 文档

APMS

应用程序消息

PMPR

Printer Maestro 打印机事件

PMIN

Printer Maestro 库存事件

SCEV

安全事件,例如权限更改

ALLR

所有记录

以下样本代码将删除超过 6 个月的所有记录。

BarTender 现在支持远程 BarTender 数据库的维护。维护可以锁定,以便每次只有一个 BarTender System Service 运行维护。因此,SpDeleteOlderRecords 程序更改为包括一个“use lock”输入参数和一个“lock host”输出参数。

如果“use lock”为非零,存储的程序会尝试锁定维护功能。如果锁定失败,程序会在“result”输出参数中返回 -9,并在“lock host”输出参数中返回当前保持该锁定的主机的名称。如果程序成功,“result”将为 1。

如果仅有一个 BarTender System Service 连接至特定 SQL Server 数据库,那么“use lock”参数可以为零,并且不会进行任何锁定尝试(因为没有必要)。

DECLARE @timeThreshold int
DECLARE @timeUnits int
DECLARE @recordType nvarchar(1024)
DECLARE @useLock int
DECLARE @lockHost nvarchar(1024)
DECLARE @result int
DECLARE @numRows int


SET @timeThreshold = 6
SET @timeUnits = 2
SET @recordType = N'ALLR'
SET @useLock = 1
SET @result = 0


EXEC [dbo].[SpDeleteOlderRecords] @timeThreshold, @timeUnits, @recordType, @useLock, @lockHost output, @result output

SpPurgeDatabase

SpPurgeDatabase 程序会移除 BarTender System Database 中包含的所有记录的数据。记录操作繁重时,建议您不要使用此过程,因为此过程可能会干扰 BarTender System Database 正在进行的记录操作。SpPurgeDatabase 流程不包含其他参数。

SpPurgeDatabase 流程不可逆。因此,您无法检索已从数据库中清除的任何记录。请谨慎使用此程序。

以下样本代码从数据库中清除所有记录。

EXEC dbo.SpPurgeDatabase