A
aboesteanu
Data is stored in SQL Server 2000. One table is Person another Item.
Each row in the Person table may have associated with it several rows
in the Item table. The Item table has a field called 'type'. Business
rule: for certain values of this field, at most one row may exist (per
Person) in the Item table.
The DB is accessed from an ASP.NET app and more than one user may try
to insert an Item of the same type (and for the same Person) at the
same type. It would be very easy to ensure the above business rule
using a trigger (on the Item table) or a stored procedure that would
do inside something like this:
IF (NOT EXISTS (SELECT ... FROM Item)) INSERT INTO Item...
Please note that, because of internal coding standards, I cannot
modify the DB and I cannot access the database from my app through
direct SQL statements (e.g., like the one above). I can only access
the Item table through stored procedures that perform inside them
simple selects and inserts on the table.
Assuming the stored procedures (for SELECT and INSERT on the Item
table) are called inside the same method, is there a way to satisfy
the above mentioned business rule (ensure mutual exclusion) at the app
level? Would specifying the isolation level as serializable at the app
level work? Is there a better solution?
Thank you,
Alex
Each row in the Person table may have associated with it several rows
in the Item table. The Item table has a field called 'type'. Business
rule: for certain values of this field, at most one row may exist (per
Person) in the Item table.
The DB is accessed from an ASP.NET app and more than one user may try
to insert an Item of the same type (and for the same Person) at the
same type. It would be very easy to ensure the above business rule
using a trigger (on the Item table) or a stored procedure that would
do inside something like this:
IF (NOT EXISTS (SELECT ... FROM Item)) INSERT INTO Item...
Please note that, because of internal coding standards, I cannot
modify the DB and I cannot access the database from my app through
direct SQL statements (e.g., like the one above). I can only access
the Item table through stored procedures that perform inside them
simple selects and inserts on the table.
Assuming the stored procedures (for SELECT and INSERT on the Item
table) are called inside the same method, is there a way to satisfy
the above mentioned business rule (ensure mutual exclusion) at the app
level? Would specifying the isolation level as serializable at the app
level work? Is there a better solution?
Thank you,
Alex