[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Updating an array



Well, I was writing in a bit of a short-hand fashion.  You need to choose a table's column as the "key" you want to use in the array (e.g. EMPLID).  Then when you are looking through the array for that employee's record you test for a match on EMPLID, like this...
 
move 0 to #i
CREATE-ARRAY NAME=PERSDATA SIZE=?   !need to predetermine size of array
    FIELD=EMPLID:CHAR
    FIELD=MED_DATA:CHAR
    FIELD=ETC:CHAR
    FIELD=DIINFO:CHAR
 
BEGIN-SELECT
EMPLID
MED_INFO
ETC
      put &EMPLID &MED_INFO &ETC into PERSDATA(#i) EMPLID MED_INFO ETC
      add 1 to #i
FROM PS_table
END-SELECT
 
BEGIN-SELECT
DI.EMPLID
DI.INFO
    do Update-PersData
FROM PS_DENTAL_INFO DI
END-SELECT
 
BEGIN-PROCEDURE
 
move 0 to #loop
WHILE #loop < #Limit
    get $EMPLID from PERSDATA(#loop)
    if $EMPLID = &DI.EMPLID
        put &DI.INFO into PERSDATA(#loop) DI_INFO
        break    ! no need to loop any further for this EMPLID
    end-if
 
END-WHILE
 
END-PROCEDURE
 
 
I hope this helps.  You should get into the Help for Arrays in SQR for further info.  I'm leaving shortly, so if you need further help today, maybe someone else can pick up where I left off.
 
HTH
Bob
-----Original Message-----
From: Kathy Mason [mailto:kmason@GIX-GLOBAL.COM]
Sent: Friday, November 05, 1999 2:29 PM
To: Multiple recipients of list SQR-USERS
Subject: Re: Updating an array

This is probably a stupid questions, but how do you make a field a key in an array?

Bob Buford-Abba Systems wrote:

 

Kathy,

Have you considered putting a key in one of the array fields, then looping through the array to find that key.  Once you've determined the element you can do numeric operations (see ARRAY-ADD, ARRAY-DIVIDE, ARRAY-MULTIPLY, and ARRAY-SUBTRACT) and you can do string operations by extracting value, operating on it and "putting" it back into the array.

HTH
Bob

-----Original Message-----
From: Kathy Mason [mailto:kmason@GIX-GLOBAL.COM]
Sent: Friday, November 05, 1999 12:32 PM
To: Multiple recipients of list SQR-USERS
Subject: Updating an array

Database Oracle 7
SQR Version 4
Platform HPUX

I was wondering if there is a simple way to update an array.

I am working on an SQR that prints data as it is selected but writes to a file
when the id changes.  I am storing dependent data in an array because one ee may
have numerous dependents.
I get their medical info and insert into an array - I need to then update array
after  I get the dental info.  Is that possible?  I couldn't file anything
referencing this in the archives or in reference books.  Perhaps I am looking
for the wrong thing.

Any help would be appreciated.

Kathy