It all starts to go wrong here. Why does update_order have a prototype of $$. That forces both arguments into scalar context. That's not a problem for the first argument as that already is a scalar, but your second argument is an _array_. When you force it into scalar context (as your prototype does) you don't get any of the data in the array - you simply get the number of elements in an array. Perl prototypes are pretty complex for beginners to understand and they are usually unnecessary. You're better off not using them at all here.

The upshot of all this is that when you assign a value to @tempArray, you get an array with one element - the number of elements in your previous array. This is a scalar _not_ a hash reference as your code almost expects. I say "almost" because you have unnecessary '%' characters in your expressions. Had you been running with "use warnings" turned on you would have got warnings about trying to use a scalar as a hash reference.

So your $lo and $id variables both end up containing the value "undef" because of your illegal hash lookups.

Also, why do you prepare the SQL statement each time round the loop? The whole point of allowing placeholders in SQL is that you can prepare it once (saying time) and execute it many times. That's not a bug, but it is a pretty stupid thing to do.

In Reply To

but when I get it from database, it will display something like this,

HASH(0x839a4f4)

See, we've got no idea what you're doing to print that. You haven't shown us the code that display that. All we know is that you're printing a hash reference.

Code

my $row = $sth->fetchrow_hashref) { $row->{LO} = $row->{LO}

This is so weird, it's hard to know what you were trying to do. You read a hash of data from the database and then you overwrite one of the values in the hash with itself. That does nothing but waste time. What do you think this code does?

Sorry if this sounds a bit harsh but not only was your code badly thought out, your question was also impossible to understand. I've done what I can. Please read some good documentation before writing any more Perl.