Subject | Re: [IBO] Help on stored procedures/trigger |
---|---|
Author | Marc Leclerc |
Post date | 2001-03-14T23:51:49Z |
Hi,
Too many break should not be happening since when entered the data stays. It
is also very very unlikely that one department receives more than 999
request in a month. The problem I see with using a table is the number of
sequence I would have to keep. Dept A enters A01 (Year 2001) - 01
(January) - Sequence, now this sequence starts back at 1 on the next month
buy one may enter a request from the past month and the sequence must follow
the one from the preceding month.
Here is a part of the code I used for the paradox application that may
explain more what the need is.
...
QueryUtility->SQL->Clear();
QueryUtility->SQL->Add("Select MAX(RequestNumber) As sMax From dsRequest
Where RequestNumber Like '" +
S.SubString(1,7) + "%'");
QueryUtility->Open();
try
{
int i = 1;
if ( !QueryUtility->FieldByName("sMax")->IsNull )
{
V = QueryUtility->FieldByName("sMax")->AsString;
i = StrToInt(V.SubString(8,3));
i++;
}
DataSet->DisableControls();
DataSet->FieldByName("RequestNumber")->AsString = S.SubString(1,7) +
V.sprintf("%3.3i", i);
TableRequestRequestNumber->EditMask = ">L00\-00\-000;1;_";
DataSet->EnableControls();
}
...
Too many break should not be happening since when entered the data stays. It
is also very very unlikely that one department receives more than 999
request in a month. The problem I see with using a table is the number of
sequence I would have to keep. Dept A enters A01 (Year 2001) - 01
(January) - Sequence, now this sequence starts back at 1 on the next month
buy one may enter a request from the past month and the sequence must follow
the one from the preceding month.
Here is a part of the code I used for the paradox application that may
explain more what the need is.
...
QueryUtility->SQL->Clear();
QueryUtility->SQL->Add("Select MAX(RequestNumber) As sMax From dsRequest
Where RequestNumber Like '" +
S.SubString(1,7) + "%'");
QueryUtility->Open();
try
{
int i = 1;
if ( !QueryUtility->FieldByName("sMax")->IsNull )
{
V = QueryUtility->FieldByName("sMax")->AsString;
i = StrToInt(V.SubString(8,3));
i++;
}
DataSet->DisableControls();
DataSet->FieldByName("RequestNumber")->AsString = S.SubString(1,7) +
V.sprintf("%3.3i", i);
TableRequestRequestNumber->EditMask = ">L00\-00\-000;1;_";
DataSet->EnableControls();
}
...
----- Original Message -----
From: "Geoff Worboys" <geoff@...>
To: <IBObjects@yahoogroups.com>
Sent: Wednesday, March 14, 2001 6:07 PM
Subject: Re: [IBO] Help on stored procedures/trigger
...
>
> Your real problem is how you are going to generate the sequence number
> safely in a multi-user environment. Another posting suggested
> selecting the sequence number from a table - but it did not do it in a
> safe manner - and it is something that is frowned upon by most
> database purists.
>
> There is an article in the IBO online help about maintaining pure
> (unbroken) sequences. I dont know whether your sequence numbers must
> be unbroken or not, but with only 3 digit I suspect that you would not
> want too many breaks.
>
>
> Is this what you were looking for?
>
> Geoff Worboys
> Telesis Computing
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>