Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select to arrays

Status
Not open for further replies.

fishman13

Programmer
Jul 8, 2002
73
0
0
US
Hi,

I am trying to figure out how to select one record from a table and access the data in an array. I am using the following select

select * from balance where alltrim(account) == ;
alltrim (csr_cbuff.account) into array holdbal

The balance table contains account
checking
savings


I was trying to access the data by holdbal.checking, holdbal.savings, but get "object holdbal does not exist". If a change the select to a cursor the information is there.


 
fishman13


PUBLIC ARRAY myArray[1]
SELECT Detail.accno, Detail.nom;
FROM client!detail;
into array myArray
FOR i = 1 TO ALEN(myArray)/2
? myArray[i,1]
ENDFOR

Or

PUBLIC ARRAY myArray[1]
Local nElement
PUBLIC ARRAY myArray[1]
SELECT Detail.accno, Detail.nom;
FROM client!detail;
into array myArray
nElement=ASCAN(myArray,"A02292")
? nElement && The element that contains the value looking for

? myArray[nElement,1] && The element value

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi fishman,

Method 1:
select * from balance where alltrim(account) == ;
alltrim(csr_cbuff.account) into CURSOR holdbal

This will create a read only cusror which you will be aware. Then you can use...holdbal.checking, holdbal.savings etc.

If you want to manipulate these figures.. make the

select * from balance where alltrim(account) == ;
alltrim(csr_cbuff.account) into CURSOR holdbal ;
READWRITE

Then you can manipulate.


Method 2:
select * from balance where alltrim(account) == ;
alltrim(csr_cbuff.account) into CURSOR holdbal
SCATTER MEMVAR

Then you can use... m.checking, m.savings etc. memory variables.

These will be more convenient in your circumstance. :)


ramani :)
(Subramanian.G)
 
The short answer is that arrays are accessed by subscripts. In your case "savings" is holdbal(1, 3).

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top