Precisely Speaking
May 18, 2012, 03:34:33 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: So what's news with you?  Tell us about it in "Getting To Know You"!
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Update A Multivalue  (Read 2152 times)
LasVegasSBUser
Professional
***
Posts: 18


« on: July 28, 2009, 10:08:44 AM »

Hello has anyone had any sucess updating 1 multivalue attribute. Basicly I have a subroutine that computes a total and writes that value to a Single Value attribute in the samefile. Next I need to load the GUI screen and I need to append a row that includes the new value. See example below.
Can I use the WRITEV command to update a multi value?


1OPEN "PSI.LUA.BILLING.DETAIL" TO PSI.LUA.BILLING.DETAIL ELSE
2     ERROR.MSG = "Unable to open PSI.LUA.BILLING.DETAIL"
3END
4KEY = WORK<1>
5CALL SB.DISP(4,'Loading Indicated Premium & Collateral Screen')
6SELECT.COMMAND = 'SELECT PSI.LUA.BILLING.DETAIL WITH @ID = "':KEY:'"'
7EXECUTE SELECT.COMMAND CAPTURING SCREEN RETURNING LIST.REC
8RECORDS.SELECTED = SYSTEM(11)
9IF RECORDS.SELECTED THEN
10   LOOP READNEXT ID ELSE ID = AM WHILE ID # AM DO
11       READ LUA.BILL.REC FROM PSI.LUA.BILLING.DETAIL,ID THEN
12             MONTH = LUA.BILL.REC<1>
13             MTD.PAY.ALL.ST = LUA.BILL.REC<14>
14             NEXT.MONTH = MONTH + 1
15       END
16   REPEAT
17   GOSUB UPDATE.NEXT.MV.ROW <----This sub is called to appened the next MV value
18   VMC.CNT = DCOUNT(MONTH,@VM)
19   FOR VMC = 1 TO VMC.CNT
20       RECORD<1,VMC> = LUA.BILL.REC<1,VMC> ;*Month Count
21       RECORD<2,VMC> = LUA.BILL.REC<2,VMC> ;*Pay From
22       RECORD<3,VMC> = LUA.BILL.REC<3,VMC> ;*Pay To
23       RECORD<4,VMC> = LUA.BILL.REC<4,VMC> ;*Payroll All States
24       RECORD<5,VMC> = LUA.BILL.REC<5,VMC> ;*Unmodifed Manual Premium
25       RECORD<6,VMC> = LUA.BILL.REC<6,VMC> ;*Deductible Premium
26       RECORD<7,VMC> = LUA.BILL.REC<7,VMC> ;*State Surcharges
27       RECORD<8,VMC> = LUA.BILL.REC<8,VMC> ;*Terrorism Premium
28       RECORD<9,VMC> = LUA.BILL.REC<9,VMC> ;*Expense Constant
29       RECORD<10,VMC> = LUA.BILL.REC<10,VMC> ;*Indicated Premium
30       RECORD<11,VMC> = LUA.BILL.REC<11,VMC> ;*Actual Payment Premuim
31       RECORD<12,VMC> = LUA.BILL.REC<12,VMC> ;*Indicated Collateral Amt
32       RECORD<13,VMC> = LUA.BILL.REC<13,VMC> ;*Actual Collateral Payment
33   NEXT VMC.CNT
34   REFRESH = -2
34 END ELSE
36  CALL SB.DISP(4,"No Record Selected")
37  RETURN
38END
***************************************************************************
UPDATE.NEXT.MV.ROW:
TEMP.LUA.BILL.REC = NIL
NEXT.VMC.POS = DCOUNT(MONTH,@VM+1)
TEMP.LUA.BILL.REC<1,NEXT.POS> = NEXT.MONTH
WRITEV TEMP.LUA.BILL.REC,ID,<1,NEXT.POS> ELSE <----------------------Will this work?
           NEXT.MONTH = ""
END
RETURN
***************************************
Logged
precisonline
President/Chief Technologist
Administrator
Rock Star
*****
Posts: 1532



WWW
« Reply #1 on: July 28, 2009, 10:19:12 AM »

Couple of things.  First, this:

NEXT.VMC.POS = DCOUNT(MONTH,@VM+1)

Should be this:

NEXT.VMC.POS = DCOUNT(MONTH,@VM)+1

Second, WRITEV is almost always a bad idea.  WRITEV is a syntax convention that causes the record to be re-read from disk, updated in memory, and then the entire record is rewritten to disk.  If you have the record in memory already, might as well update it there.  And if you don't, I'd recommend reading the entire record, updating it, and then writing the entire record in your own code.  It may seem like a lot more code to do this but later when you need to update something else in the record the change is nominal.

It appears you're wanting to load a bunch of information into memory, but as I'm reading this MONTH can never be more than a single value.  Is that what you intended?  Is it imperative that the new value you're adding be written to the record or can it just appear on a screen?
Logged

-Kevin
Accidents "happen"; success, however, is planned and executed.
LasVegasSBUser
Professional
***
Posts: 18


« Reply #2 on: July 28, 2009, 10:23:48 AM »

Ok makes good since, I do like the WRITEV command, but I see your point on why it may be a problem.
Logged
precisonline
President/Chief Technologist
Administrator
Rock Star
*****
Posts: 1532



WWW
« Reply #3 on: July 28, 2009, 12:19:26 PM »

Of course, WRITEV alone isn't bad.  But it opens the door for someone to follow six months from now and add another one and another one and then a couple of years later you have six of those babies lined up reading different attributes out of the same record and performance just goes kaput.  So I'm of the mindset to not even start down that road.
Logged

-Kevin
Accidents "happen"; success, however, is planned and executed.
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!