Subject | Which transaction property setting should I be using for reports? |
---|---|
Author | SoftTech |
Post date | 2010-04-16T03:58:06Z |
Greetings All,
Using Firebird 1.5
Delphi 5.1
Interbase express components
TDataSource -> TClientDataset -> TDataSetProvider -> TIBQuery ->
TIBTransaction and TIBDatabase
Currently I use Read-Only Table Stability (Which I'm sure is wrong)
My Issue:
For some reason I have a report which looks like it freezes up, but in fact
I think there is a update lock conflict error and not sure why. While the
report looks to be frozen, we will ask other users to get out of the app and
the report finishes instantly. With others out the report works flawlessly
without hanging.
The SQL for the query:
SELECT * FROM SPS_ACTIVE_DEBT_RPT_MASTER(:BeginListDate, :EndListDate,
:CltSiteID)
The Stored Procedure:
SET TERM ^^ ;
CREATE PROCEDURE SPS_ACTIVE_DEBT_RPT_MASTER (
V_BEGIN_LIST_DATE Date,
V_END_LIST_DATE Date,
V_CLT_SITE_ID SmallInt)
returns (
ACCT_ID Integer,
CASE_ID SmallInt,
ACCT_REF_NO VarChar(20),
CLT_SITE_NAME VarChar(50),
DEBTOR_NAMES VarChar(160),
ORIG_PRINCIPAL Numeric(15,2),
CUR_PRINCIPAL Numeric(15,2),
ORIG_FEE Numeric(15,2),
CUR_FEE Numeric(15,2),
ORIG_PRE_JUD_INT Numeric(15,2),
CUR_PRE_JUD_INT Numeric(15,2),
ORIG_POST_JUD_INT Numeric(15,2),
CUR_POST_JUD_INT Numeric(15,2),
BALANCE_DUE Numeric(15,2),
STATUS_DESC VarChar(40))
AS
DECLARE VARIABLE iForwardedDebt SmallInt;
DECLARE VARIABLE sStatusCode Char(1);
begin
FOR SELECT DISTINCT AC.ACCT_ID,
AC.CASE_ID,
AC.ACCT_ID || '-' || AC.CASE_ID AS ACCT_REF_NO,
AC.STATUS_CODE,
CS.SITE_NAME,
(SELECT R_DEBTOR_NAMES
FROM SPS_GET_DEBTOR_NAMES_STRING (D.ACCT_ID,
D.CASE_ID, D.DEBT_NO)) AS DEBTOR_NAMES,
(AC.ORIG_PRINCIPAL + AC.ADJ_PRINCIPAL) AS
ORIG_PRINCIPAL,
((AC.ORIG_PRINCIPAL + AC.ADJ_PRINCIPAL) -
AC.PAID_PRINCIPAL) AS CUR_PRINCIPAL,
(AC.ORIG_FEE + AC.ADJ_FEE) AS ORIG_FEE,
((AC.ORIG_FEE + AC.ADJ_FEE) - AC.PAID_FEE) AS CUR_FEE,
(AC.PRE_JUDGMENT_ACCRUED_INTEREST +
AC.PRE_JUDGMENT_ADJ_INTEREST) AS ORIG_PRE_JUD_INT,
((AC.PRE_JUDGMENT_ACCRUED_INTEREST +
AC.PRE_JUDGMENT_ADJ_INTEREST) - AC.PRE_JUDGMENT_PAID_INTEREST) AS
CUR_PRE_JUD_INT,
(AC.POST_JUDGMENT_ACCRUED_INTEREST +
AC.POST_JUDGMENT_ADJ_INTEREST) AS ORIG_POST_JUD_INT,
((AC.POST_JUDGMENT_ACCRUED_INTEREST +
AC.POST_JUDGMENT_ADJ_INTEREST) - AC.POST_JUDGMENT_PAID_INTEREST) AS
CUR_POST_JUD_INT,
(((AC.ORIG_PRINCIPAL + AC.ADJ_PRINCIPAL) -
AC.PAID_PRINCIPAL) +
((AC.ORIG_FEE + AC.ADJ_FEE) - AC.PAID_FEE) +
((AC.PRE_JUDGMENT_ACCRUED_INTEREST +
AC.PRE_JUDGMENT_ADJ_INTEREST) - AC.PRE_JUDGMENT_PAID_INTEREST) +
((AC.POST_JUDGMENT_ACCRUED_INTEREST +
AC.POST_JUDGMENT_ADJ_INTEREST) - AC.POST_JUDGMENT_PAID_INTEREST)) AS
BALANCE_DUE,
/* CASE AC.CUR_COMPANY_ID
WHEN AC.ORIG_COMPANY_ID THEN 0
ELSE 1
END AS FORWARDED_DEBT */
CAST(0 AS SMALLINT) AS FORWARDED_DEBT
FROM ACCT_CASE AC
JOIN CLIENT_SITE CS ON CS.CLT_SITE_ID = AC.CLT_SITE_ID
JOIN DEBT D ON D.ACCT_ID = AC.ACCT_ID
AND D.CASE_ID = AC.CASE_ID
WHERE AC.STATUS_CODE IN ('A','O')
AND D.LIST_DATE BETWEEN :V_BEGIN_LIST_DATE AND :V_END_LIST_DATE
AND CS.CLT_SITE_ID = :V_CLT_SITE_ID
ORDER BY D.ACCT_ID, D.CASE_ID, D.DEBT_NO
INTO :ACCT_ID, :CASE_ID, :ACCT_REF_NO, :sStatusCode,
:CLT_SITE_NAME, :DEBTOR_NAMES,
:ORIG_PRINCIPAL, :CUR_PRINCIPAL, :ORIG_FEE, :CUR_FEE,
:ORIG_PRE_JUD_INT,
:CUR_PRE_JUD_INT, :ORIG_POST_JUD_INT, :CUR_POST_JUD_INT,
:BALANCE_DUE, :iForwardedDebt DO
BEGIN
IF (sStatusCode = 'A') THEN
STATUS_DESC = 'Active';
ELSE IF (sStatusCode = 'O') THEN
STATUS_DESC = 'On-Hold';
/* If debt has been forwarded, add that to status */
IF (iForwardedDebt = 1) then
STATUS_DESC = 'Sent to Legal - ' || STATUS_DESC;
SUSPEND;
END
end
^^
SET TERM ; ^^
As you can see the stored procedure simply selects data from the database
for the report.
Which settings should I use for reports to avoid causing a lock update
conflict error elsewhere in my Application?
The report should simply pull the latest data available in the database and
not worry if someone else is updating a database.
So should I use one of the four defaults or set my own in the settings list?
Any help would really be appreciated.
Thanks,
Mike
Using Firebird 1.5
Delphi 5.1
Interbase express components
TDataSource -> TClientDataset -> TDataSetProvider -> TIBQuery ->
TIBTransaction and TIBDatabase
Currently I use Read-Only Table Stability (Which I'm sure is wrong)
My Issue:
For some reason I have a report which looks like it freezes up, but in fact
I think there is a update lock conflict error and not sure why. While the
report looks to be frozen, we will ask other users to get out of the app and
the report finishes instantly. With others out the report works flawlessly
without hanging.
The SQL for the query:
SELECT * FROM SPS_ACTIVE_DEBT_RPT_MASTER(:BeginListDate, :EndListDate,
:CltSiteID)
The Stored Procedure:
SET TERM ^^ ;
CREATE PROCEDURE SPS_ACTIVE_DEBT_RPT_MASTER (
V_BEGIN_LIST_DATE Date,
V_END_LIST_DATE Date,
V_CLT_SITE_ID SmallInt)
returns (
ACCT_ID Integer,
CASE_ID SmallInt,
ACCT_REF_NO VarChar(20),
CLT_SITE_NAME VarChar(50),
DEBTOR_NAMES VarChar(160),
ORIG_PRINCIPAL Numeric(15,2),
CUR_PRINCIPAL Numeric(15,2),
ORIG_FEE Numeric(15,2),
CUR_FEE Numeric(15,2),
ORIG_PRE_JUD_INT Numeric(15,2),
CUR_PRE_JUD_INT Numeric(15,2),
ORIG_POST_JUD_INT Numeric(15,2),
CUR_POST_JUD_INT Numeric(15,2),
BALANCE_DUE Numeric(15,2),
STATUS_DESC VarChar(40))
AS
DECLARE VARIABLE iForwardedDebt SmallInt;
DECLARE VARIABLE sStatusCode Char(1);
begin
FOR SELECT DISTINCT AC.ACCT_ID,
AC.CASE_ID,
AC.ACCT_ID || '-' || AC.CASE_ID AS ACCT_REF_NO,
AC.STATUS_CODE,
CS.SITE_NAME,
(SELECT R_DEBTOR_NAMES
FROM SPS_GET_DEBTOR_NAMES_STRING (D.ACCT_ID,
D.CASE_ID, D.DEBT_NO)) AS DEBTOR_NAMES,
(AC.ORIG_PRINCIPAL + AC.ADJ_PRINCIPAL) AS
ORIG_PRINCIPAL,
((AC.ORIG_PRINCIPAL + AC.ADJ_PRINCIPAL) -
AC.PAID_PRINCIPAL) AS CUR_PRINCIPAL,
(AC.ORIG_FEE + AC.ADJ_FEE) AS ORIG_FEE,
((AC.ORIG_FEE + AC.ADJ_FEE) - AC.PAID_FEE) AS CUR_FEE,
(AC.PRE_JUDGMENT_ACCRUED_INTEREST +
AC.PRE_JUDGMENT_ADJ_INTEREST) AS ORIG_PRE_JUD_INT,
((AC.PRE_JUDGMENT_ACCRUED_INTEREST +
AC.PRE_JUDGMENT_ADJ_INTEREST) - AC.PRE_JUDGMENT_PAID_INTEREST) AS
CUR_PRE_JUD_INT,
(AC.POST_JUDGMENT_ACCRUED_INTEREST +
AC.POST_JUDGMENT_ADJ_INTEREST) AS ORIG_POST_JUD_INT,
((AC.POST_JUDGMENT_ACCRUED_INTEREST +
AC.POST_JUDGMENT_ADJ_INTEREST) - AC.POST_JUDGMENT_PAID_INTEREST) AS
CUR_POST_JUD_INT,
(((AC.ORIG_PRINCIPAL + AC.ADJ_PRINCIPAL) -
AC.PAID_PRINCIPAL) +
((AC.ORIG_FEE + AC.ADJ_FEE) - AC.PAID_FEE) +
((AC.PRE_JUDGMENT_ACCRUED_INTEREST +
AC.PRE_JUDGMENT_ADJ_INTEREST) - AC.PRE_JUDGMENT_PAID_INTEREST) +
((AC.POST_JUDGMENT_ACCRUED_INTEREST +
AC.POST_JUDGMENT_ADJ_INTEREST) - AC.POST_JUDGMENT_PAID_INTEREST)) AS
BALANCE_DUE,
/* CASE AC.CUR_COMPANY_ID
WHEN AC.ORIG_COMPANY_ID THEN 0
ELSE 1
END AS FORWARDED_DEBT */
CAST(0 AS SMALLINT) AS FORWARDED_DEBT
FROM ACCT_CASE AC
JOIN CLIENT_SITE CS ON CS.CLT_SITE_ID = AC.CLT_SITE_ID
JOIN DEBT D ON D.ACCT_ID = AC.ACCT_ID
AND D.CASE_ID = AC.CASE_ID
WHERE AC.STATUS_CODE IN ('A','O')
AND D.LIST_DATE BETWEEN :V_BEGIN_LIST_DATE AND :V_END_LIST_DATE
AND CS.CLT_SITE_ID = :V_CLT_SITE_ID
ORDER BY D.ACCT_ID, D.CASE_ID, D.DEBT_NO
INTO :ACCT_ID, :CASE_ID, :ACCT_REF_NO, :sStatusCode,
:CLT_SITE_NAME, :DEBTOR_NAMES,
:ORIG_PRINCIPAL, :CUR_PRINCIPAL, :ORIG_FEE, :CUR_FEE,
:ORIG_PRE_JUD_INT,
:CUR_PRE_JUD_INT, :ORIG_POST_JUD_INT, :CUR_POST_JUD_INT,
:BALANCE_DUE, :iForwardedDebt DO
BEGIN
IF (sStatusCode = 'A') THEN
STATUS_DESC = 'Active';
ELSE IF (sStatusCode = 'O') THEN
STATUS_DESC = 'On-Hold';
/* If debt has been forwarded, add that to status */
IF (iForwardedDebt = 1) then
STATUS_DESC = 'Sent to Legal - ' || STATUS_DESC;
SUSPEND;
END
end
^^
SET TERM ; ^^
As you can see the stored procedure simply selects data from the database
for the report.
Which settings should I use for reports to avoid causing a lock update
conflict error elsewhere in my Application?
The report should simply pull the latest data available in the database and
not worry if someone else is updating a database.
So should I use one of the four defaults or set my own in the settings list?
Any help would really be appreciated.
Thanks,
Mike