Friday, January 15, 2010

Matter Exception Rate Update

Occasionally we have the need to input matter exception rates for a number of matters for a client, but not all (hence matter exceptions and not client exceptions). To my knowledge, there are at least three ways to accomplish this. 1) Manually input exception rates on all matters that need them (but what if there's 50!). 2) If you're on 3.5 or higher, you can create a matter udf called CEXRATE and input a different client number to utilise that client's exception rates. You could then create a dummy client, load the exception rates once and add this client number to each matter in the CEXRATE udf. 3) You can use the method below.

Step 1 - Input exception rates for one matter. Then view the exception rates in SQL. We want to copy the last row with the effective date of 5/1/2004.

SELECT *
FROM mexrate
WHERE mrmatter='2000-001'
Results


mrmattermrtkmreffdatemrratemrdevpermrdevdolmrccodemrtitlemrmaximummrreasonmrrtnum
2000-001!2000-01-01 00:00:00.000200.000NULLNULL!Senior PartnerNNULLNULL
2000-001!2003-01-01 00:00:00.000250.000NULLNULL!Senior PartnerNNULLNULL
2000-001!2003-03-01 00:00:00.000300.000NULLNULL!Senior PartnerNNULLNULL
2000-001!2003-05-01 00:00:00.000350.000NULLNULL!Senior PartnerNNULLNULL
2000-001!2004-04-01 00:00:00.000400.000NULLNULL!Senior PartnerNNULLNULL
2000-001!2004-05-01 00:00:00.000500.000NULLNULL!Senior PartnerNNULLNULL

Step 2 - Create temporary table to hold matters that need the exception rates & populate.

CREATE TABLE ##mexrate1
( mmatter VARCHAR(15));

INSERT INTO ##mexrate1 VALUES ('2000-003')
INSERT INTO ##mexrate1 VALUES ('2000-010')
...
--If there is a systematic way to identify the matters then you can use:
INSERT INTO ##mexrate1
SELECT mmatter
FROM matter
WHERE ...(your criteria)...
Step 3 - Execute cursor update below to cycle through the matters and insert new exception rates
BEGIN TRANSACTION mexrateupdate

Declare c Cursor For Select Distinct mmatter From ##mexrate1
Open c

DECLARE @MatId VARCHAR (15);

Fetch next From c into @MatId

While @@Fetch_Status=0 Begin

INSERT INTO mexrate
SELECT @MatId,
 mrtk,
 mreffdate,
 mrrate,
 mrdevper,
 mrdevdol,
 mrccode,
 mrtitle,
 mrmaximum,
 mrreason,
 mrrtnum
FROM mexrate
WHERE mrmatter = '2000-001' --The original matter to copy
 AND mreffdate = '5/1/2004' --The exception rates to copy

   Fetch next From c into @MatId
End

Close c
Deallocate c
Step 4 - Use SQL to view a matter that was updated & make sure everything looks good
SELECT *
FROM mexrate
WHERE mrmatter = '2000-010'
Step 5 - Check the matter in Elite to make sure everything looks ok.
Step 6 - If it's all good, commit the transaction (if not, rollback)
ROLLBACK TRANSACTION mexrateupdate --if it's bad
COMMIT TRANSACTION mexrateupdate --if it's good
Step 7 - Explicitly drop the temporary table
DROP TABLE ##mexrate1
Step 8 - Be thankful you didn't have to manually input 25 exception rates for 75 matters...


DISCLAIMER - As always, test liberally in a test environment and deploy cautiously.

No comments:

Post a Comment