Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hey monks, I could do with some real help. Before going any further, yes, I would prefer to be using DBI/dbd, but that's not the point. I need to submit a MySQL query, then take the result and declare it as a new variable.
$mySQL->query(q{ SELECT * from table ORDER by column desc LIMIT 1; }); my $nextValue = $mySQL->create_record_iterator; while (my $record = $nextValue->each) { printf "%d\n", $record->[0]; }
returns what I need to use as a variable, however it seems I can't just initiate from $nextvalue or $record. Can anyone come up with a clever work around?

Replies are listed 'Best First'.
Re: Help with using Net::SQL and declaring results as a variable
by GotToBTru (Prior) on Dec 16, 2014 at 20:53 UTC

    What do you mean by "I can't just initiate"? I'm not understanding what the problem is. Please show which modules you are using.

    1 Peter 4:10
Re: Help with using Net::SQL and declaring results as a variable
by chacham (Prior) on Dec 17, 2014 at 15:59 UTC

    Side point: "SELECT *" should only be used in EXISTS() clauses (the entire SELECT * FROM is redundant) and ad hoc queries. When writing actual code, specify the columns. Not only does this avoid bugs due to column reordering, catch errors in view changes, and save network bandwidth, it also is self-documenting.

Re: Help with using Net::SQL and declaring results as a variable
by Anonymous Monk on Dec 16, 2014 at 19:53 UTC
    Net::MySQL *