If you ever go to StaticDB this method won't work.  You want something that 
will not break in the future.

Here is a sample of what I did

RULES 'Order is closed, cannot update.' FOR MyTable SUCCEEDS WHERE 
(CVAL('USER')) = ('CLOSED') OR FAILS (SELECT IDColumn FROM MyTableClosed t1 
WHERE t1.IDColumn = MyTable.IDColumn)

RULES 'Order is closed, cannot delete.' FOR MyTable DELETE  SUCCEEDS WHERE 
(CVAL('USER')) = ('CLOSED') OR FAILS (SELECT IDColumn FROM MyTableClosed t1 
WHERE t1.IDColumn = MyTable.IDColumn)

Adding appropriate records to MyTableClosed locks the related record in MyTable

You can easily turn the rule off by temporarily changing NAME:
SET VAR VTmpName = (CVAL('NAME'))
SET NAME 'CLOSED'
--Do updates
--Add missing MyTableClosed records
SET NAME &vTmpName

Dennis McGrath

________________________________
From: [email protected] [mailto:[email protected]] On Behalf Of jan johansen
Sent: Friday, March 06, 2009 1:14 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - RE: Locking a row

Dennis,

Thanks for checking. I was pulling my hair out because I couldn't update the row
to lock it. I think another thing I could try is to
1. create the rule on the table
2. Update the columns that need updating
3. drop the rule
4. update the rule column
5. reapply the rule

R:Base is so fast that this may not even be noticible. On a weekly basis this 
would
only be less than 100 rows to be updated.

Jan




-----Original Message-----
From: Dennis McGrath <[email protected]>
To: [email protected] (RBASE-L Mailing List)
Date: Fri, 6 Mar 2009 09:27:05 -0600
Subject: [RBASE-L] - RE: Locking a row
Use (CVAL('NAME')) in the rule

________________________________
From: [email protected] [mailto:[email protected]] On Behalf Of Dennis McGrath
Sent: Friday, March 06, 2009 9:08 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - RE: Locking a row

I just tried it myself, and apparently the check cannot be against the same 
table.
I ran into this myself some time ago but did not remember this limitation.

What I eventually did was make sure my table had a primary key, and created a 
control table with a foreign key to this.
I made a rule that editing succeed if the foreign key did not exist.
When I want to lock a particular record, I just insert its key in the control 
table.
I included in the rule that if NAME equals a special value the records are also 
editable.

This is actually pretty elegant because you can reopen a record by deleting its 
companion in the control table or by setting NAME to the correct value.

Dennis McGrath






________________________________
From: [email protected] [mailto: [email protected]] On Behalf Of jan johansen
Sent: Thursday, March 05, 2009 5:43 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - RE: Locking a row

Dennis,

Actually I spoke to soon. I'm having a dickens of a time
to get this rule correct. Any suggestions appreciated.

Jan


-----Original Message-----
From: Dennis McGrath <[email protected]>
To: [email protected] (RBASE-L Mailing List)
Date: Thu, 5 Mar 2009 14:55:16 -0600
Subject: [RBASE-L] - RE: Locking a row
Add a column to the table i.e. MyTableFlag INT default 0

Create a rule that only allows the row to be updated if this column = 0

When your routine has completed for a row, it changed the column to 1

Dennis McGrath


________________________________
From: [email protected] [mailto: [email protected]] On Behalf Of jan johansen
Sent: Thursday, March 05, 2009 2:47 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Locking a row

Group,

I need to think up a method to not allow ANY modification to a row after a 
certain routine
has been completed.

I know how to limit access to it from a form but might there be a way to 
disable edit on a row?
A row trigger maybe?

Jan

Reply via email to