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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help breaking down data

Status
Not open for further replies.

veteq

Technical User
Dec 7, 2004
23
CA
I am retrieving data from a remote database....

Code:____________________________________________________

while (@data = $sth->fetchrow_array())
{
print "@data[0]\t\t@data[1]\t\t@data[2]\n";
}

_________________________________________________________

this is the code and it works but I need to break it down further, right now @data[0] contains 10 records, I need to move that data to a different array where
item[0] = 1st record of @data[0]
item[1] = 2nd record of @data[0]
...
item[10] = 10th record of @data[0]

so I can manipulate the data,


any help would be greatly apreciated

veteq

 
while (@data = $sth->fetchrow_array())
{
$usrloadid = $data[0];
$usrwsku = $data[1];
$usrlocation = $data[2];

@keeper[$kounter]=$usrloadid;
$kounter +=1;
};


I managed to load the data to an array this way but there must be a cleaner way.....

any thoughts....thank you
 
Needs a bit of clarification: what does @data[0] look like? How are the records delimited?

You'll probably end up using the split function.
 
Sorry about that,

I am connecting to an Oracle db and retrieving the data through a Select stmt

This is how the code is looking but I am looking for a better way to do it

my $sth = $dbh->prepare('select OPID, PASSWD, EMPNUM from EMPINFO');
--------------------------------------------------------
--------------------------------------------------------
while (@data = $sth->fetchrow_array())
{
@arrayloadid[$kounter] =$data[0];
@arraywsku[$kounter] =$data[1];
@arraylocation[$kounter] =$data[2];
$kounter +=1;
};
 
Code:
my @keeper;
while ($usrloadid, $usrwsku,$usrlocation) = $sth->fetchrow_array()) {
 $keeper[$kounter]=$usrloadid;
 $kounter++;
}

This should work, in theory at least

--Paul


Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
thank you Paul, I will try it tomorrow


Veteq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top