Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: How to add columns with new row name using perl from mysql query?

by finddata (Sexton)
on Apr 06, 2017 at 12:08 UTC ( #1187263=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to add columns with new row name using perl from mysql query?
in thread How to add columns with new row name using perl from mysql query?

I HAD USED AS FOLLOWS BUT IT THROWS AN ERROR AS could not in7sert_run_pend data
sub pending_running_partition { $var_data_running = ""; $var_data_pending = ""; my $str= shift; $DBH = &connect or die "Cannot connect to the sql server \n"; $DBH->do("USE $str;"); my $stmt="select queue_name,jobs_pending,jobs_running from(select +queue_name,jobs_pending,jobs_running from queues order by queue_name +limit 5)union all select 'others',sum(jobs_pending) as jobs_pending,s +um(jobs_running) as jobs_running from (select jobs_pending,jobs_runni +ng from queues order by queue_name limit -1 offset 5"; my $sth = $DBH->prepare( $stmt ); $sth->execute() or print "Could not in7sert_run_pend data"; my $tmp = 0; while(my @row_array=$sth->fetchrow_array) { if ($tmp == 0) { $var_data_running .= "\[\"$row_array[0] \($row_array[2]\)\",$r +ow_array[2]\]"; $var_data_pending .= "\[\"$row_array[0] \($row_array[1]\)\",$r +ow_array[1]\]"; $tmp++; } else { $var_data_running .= ",\[\"$row_array[0] \($row_array[2]\)\",$ +row_array[2]\]"; $var_data_pending .= ",\[\"$row_array[0] \($row_array[1]\)\",$ +row_array[1]\]"; } } $sth->finish; $DBH->disconnect(); }
  • Comment on Re^4: How to add columns with new row name using perl from mysql query?
  • Download Code

Replies are listed 'Best First'.
Re^5: How to add columns with new row name using perl from mysql query?
by Corion (Pope) on Apr 06, 2017 at 12:12 UTC

    There is no error message COULD NOT INSERT DATA in your code.

    Please show the exact error message you get, and the exact code you are running.

    Also consider creating your database connection with the RaiseError flag so that DBI automatically tells you when an error happens.

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1187263]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2020-10-25 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (249 votes). Check out past polls.

    Notices?