Hi Alastair,
you are right in that it's not so easy as it seems from the 1st look.
I think this should work now:
RULE 'Limit of [ 10 ] entries reached!' FOR Top10_Performances SUCC+
WHERE 10 > (SELE (COUNT(*)) FROM Top10_Performances T1 WHERE+
T1.Inst_Type = Top10_Performances.Inst_Type AND T1.Top10_Performan_ID+
<> Top10_Performances.Top10_Performan_ID)
The idea belongs to Lawrence Lustig and JM (see attachment) and is this:
1. You need to have a primary key (Top10_Performan_ID) on this table, so you
can exclude the current row from the COUNT.
2. You can use a (sub-) SELECT as a 2nd operand in a WHERE clause
For the check of null values I would prefer NOT NULL Constraint.
Regards
Polychronis T. Kontos
Athens, Greece
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
> Alastair Burr
> Sent: Tuesday, January 28, 2003 10:46 PM
> To: RBASE-L Mailing List
> Subject: [RBASE-L] - Re: Rule problem
>
>
> Thanks, Eloen,
>
> I tried your suggestion straight away and I think that the rule works (see
> below) - with one change:
> I replaced:
> T1.Inst_Type = Top10_Performances.Inst_Type
> with:
> T1.Inst_Type IS NOT NULL
>
> That's a better solution than an (otherwise useless) view but I can still
> add more than
> 10 rows with the same Inst_Type from the browser/editor as long as I don't
> leave the editor. As soon as I leave and go back then the rule message
> appears when I try to edit where the count is more than 10.
>
> There's a simple work around - run the edit for 1 row at a time
> in a loop -
> but I'd love to know why there appears to be some sort of "delay" in the
> count being updated.
>
> Can anybody say whether R:Base updates itself internally between each row
> addition or only at the end of an edit command - be it "edit *
> from ..." or
> "edit using [formname]..."? I'd always thought that it would have to be
> instant - especially in a multi-user situation.
>
> Would someone mind creating - copy & paste - the simple test DB
> below and see if the same result occurs?
>
> SET QUOTES=NULL
> SET QUOTES='
> SET DELIMIT=NULL
> SET DELIMIT=','
> SET LINEEND=NULL
> SET LINEEND='^'
> SET SEMI=NULL
> SET SEMI=';'
> SET PLUS=NULL
> SET PLUS='+'
> SET SINGLE=NULL
> SET SINGLE='_'
> SET MANY=NULL
> SET MANY='%'
> SET IDQUOTES=NULL
> SET IDQUOTES='`'
> SET CASE OFF
> SET AUTOSKIP OFF
> SET REVERSE ON
> SET BELL OFF
> SET NULL '-0- '
> SET TOLERANCE 0.
> SET ZERO ON
> DISCONNECT
> SET STATICDB OFF
> SET ROWLOCKS OFF
> SET FASTLOCK OFF
> CREATE SCHEMA AUTHOR ADBTEST PUBLIC
> CREATE TABLE `Top10_Performances` +
> (`Inst_Type` TEXT (1) )
> LOAD `Top10_Performances`
> NONUM
> 'a'
> 'b'
> 'c'
> 'a'
> 'a'
> 'a'
> 'z'
> 'z'
> 'z'
> 'z'
> 'z'
> 'z'
> 'z'
> 'z'
> END
> RULES 'Fail' +
> FOR `Top10_Performances` SUCCEEDS +
> WHERE (NOT Top10_Performances.Inst_Type IN (SELECT Inst_+
> Type FROM Top10_Performances T1 WHERE T1.Inst_Type+
> IS NOT NULL) OR Top10_Performances.Inst_Type IN (+
> SELECT T2.Inst_Type FROM Top10_Performances T2 GRO+
> UP BY T2.Inst_Type HAVING COUNT(*) < 10))
> DISCONNECT
>
> CONN ADBTEST
> EDIT * FROM Top10_Performances
> RETURN
>
> Try making all the rows the same, then making 10 the same and the other
> different & leave the edit and return and try to make an 11th row
> the same.
>
>
> Thanks & regards,
> Alastair.
>
>
> ----- Original Message -----
> From: "ELOEN" <[EMAIL PROTECTED]>
> To: "RBASE-L Mailing List" <[EMAIL PROTECTED]>
> Sent: Tuesday, January 28, 2003 10:07 AM
> Subject: [RBASE-L] - Re: Rule problem
>
>
> > Hi Albert,
> >
> > try this:
> >
> > RULES 'Limit of [ 10 ] entries reached!' FOR Top10_Performances SUCCEEDS
> > WHERE+
> > Inst_Type NOT IN (SELE Inst_Type FROM Top10_Performances T1 WHERE+
> > T1.Inst_Type = Top10_Performances.Inst_Type) OR Inst_Type IN (SELE
> > T2.Inst_Type+
> > FROM Top10_Performances T2 GROUP BY T2.Inst_Type HAVI COUNT(*) < 10)
> >
> > Polychronis T. Kontos
> > Athens, Greece
>
���: [EMAIL PROTECTED] �� ������ Lawrence Lustig
[[EMAIL PROTECTED]]
��������: �������, 25 ����������� 2002 7:03 ��
����: [EMAIL PROTECTED]
����: Re: Looking for a rules
Hi JM. See answer at bottom. . .
> I have a table that contains the components for a receipt.
> Each row contains 3 columns :
>
> Receipt TEXT (8)
> Component TEXT (8)
> Weight_Percentage DOU
>
> I am looking for a rule able to prevent user to enter new rows or change
> existing rows such as the sum of Weight-Percentage stay less or equal to
> 100 %
>
> I tryed :
> RULES 'Receipt incorrect' FOR composition SUCCEEDS +
> WHERE (100 -Weight_Percentage) >= (SELECT SUM(Weight_Percentage)
FROM
> composition T1 +
> WHERE T1.Receipt = composition.Receipt)
This is almost the answer. The problem is that you need to have a primary
key on this table, so you can exclude the current row from the SUM if the
row has already been added. Assuming the key is CompID, try the rule like
this:
RULES 'Receipt incorrect' FOR composition SUCCEEDS +
WHERE (100 -Weight_Percentage) >= +
(SELECT SUM(Weight_Percentage) FROM composition T1 +
WHERE T1.Receipt = composition.Receipt AND +
T1.CompID <> Composition.CompID)
I did a quick test with this rule using both insert and update (from the
browser) and it appears to give the results you want.
--
Larry
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/