Subject | [IBO] Help on stored procedures/trigger |
---|---|
Author | Paul Irwin |
Post date | 2001-03-14T18:49:16Z |
You might want to consider splitting these values into multiple fields in
the database. You could have a calculated field to represent the
concatenation of the three values.
so if you made two fields, one for the "[A-Z]Year-Month" called 'YM_Value'
and one for the "Sequencial number" called 'Sequence'.
That way you could have a trigger like this.
SET TERM !!;
CREATE TRIGGER Trigger1 FOR SomeTable
ACTIVE BEFORE INSERT POSITION 0
AS
DECLARE VARIABLE YMCount AS INTEGER;
BEGIN
/*Gets current count of matching values*/
SELECT COUNT(YM_Value) FROM SomeTable WHERE YM_Value = New.YM_Value INTO
YMCount;
/*Increment count for new value*/
YMCount = YMCount + 1;
/*Set Sequence value of new record*/
New.Sequence = YMCount;
END!!
SET TERM ;!!
If you want to stay with 1 field I'm not sure how to do the get current
count step.
Hope that helps,
Paul
the database. You could have a calculated field to represent the
concatenation of the three values.
so if you made two fields, one for the "[A-Z]Year-Month" called 'YM_Value'
and one for the "Sequencial number" called 'Sequence'.
That way you could have a trigger like this.
SET TERM !!;
CREATE TRIGGER Trigger1 FOR SomeTable
ACTIVE BEFORE INSERT POSITION 0
AS
DECLARE VARIABLE YMCount AS INTEGER;
BEGIN
/*Gets current count of matching values*/
SELECT COUNT(YM_Value) FROM SomeTable WHERE YM_Value = New.YM_Value INTO
YMCount;
/*Increment count for new value*/
YMCount = YMCount + 1;
/*Set Sequence value of new record*/
New.Sequence = YMCount;
END!!
SET TERM ;!!
If you want to stay with 1 field I'm not sure how to do the get current
count step.
Hope that helps,
Paul