Subject Re: Password-Lock a row in a table
Author Adam
What about a control or gateway table

For example

MyTable
(
ID,
Name,
Details
)

Sec_MyTable
(
ID,
MyTableID,
PasswordHash
)

Your trigger could then raise the exception if there exists a record
in this table with your MyTableID. You could then control the adding
and removal of the Sec_MyTable entries with a stored procedure, and
implement the password hash inside a UDF.

Adam



--- In firebird-support@yahoogroups.com, "yuraukar" <yuraukar@h...>
wrote:
>
> I am trying to password-lock a row in a table. The purpose is as
follows:
> A user should be able to lock an individual row in a table from
> modification (no, this has nothing to do with concurrency).
> Any attempt to modify data in that row should then be rejected.
>
> The easy solution is to have a column that stores the password
(could
> be encrypted, but for testing it's clear text). If the column is
NULL,
> any changes are accepted, otherwise they are rejected through a
trigger
>
> CREATE TRIGGER protect_my_table FOR my_table
> ACTIVE BEFORE UPDATE POSITION 1
> AS
> BEGIN
> IF (OLD.passwd IS NOT NULL) THEN BEGIN
> EXCEPT protection_exception;
> END
> END
>
> This however also locks the user from removing the password to
unlock
> the row later on. I was thinking about a stored procedure that -
given
> the password and row ID - would remove the password, but came to no
> working AND secure solution.
>
> Any help or ideas from the group?
>
> Yuraukar.
>
> BTW: Thanks for the very very good support from the FB team here!
You
> have saved my from numerous troubles and increased my understanding
of
> databases in general and firebird very much.