Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Perl DBI update tables

by huck (Prior)
on Dec 07, 2016 at 00:22 UTC ( [id://1177348]=note: print w/replies, xml ) Need Help??


in reply to Perl DBI update tables

It doesnt help when you dont show all the basics ... what is the assignment for $activate_info?

my guess is

$activate_info =$dbh?->prepare("SELECT * FROM ...");

and you are getting more variables than you need. Remember how i showed you how to select only the variables you need and in the proper order in your last mistake? use that method

Replies are listed 'Best First'.
Re^2: Perl DBI update tables
by kcott (Archbishop) on Dec 07, 2016 at 01:10 UTC
    "... what is the assignment for $activate_info?"

    ++ That's a very valid point.

    In my response, I assumed that was selecting the 15 columns named in the INSERT statement (source_code, ..., push). I then removed the 3 elements from @activate_results for which placeholders did not exist (i.e. the indices 2, 5 & 7) creating the array slice. That could be an incorrect assumption on my part.

    — Ken

      true, but I am selecting 15 values, I am not sure where its getting 12 from

        You wrote:

        "... I am selecting 15 values, I am not sure where its getting 12 from"

        After I wrote:

        "... I assumed that was selecting the 15 columns ... I then removed the 3 elements ... for which placeholders did not exist ..."
        15 - 3 = 12

        But you don't even need that simple arithmetic: simply count the placeholders in the VALUES clause of your INSERT statement.

        I suspect you're missing something very fundamental: maybe a lack of knowledge or understanding. Perhaps revisit DBI; in particular, the "Placeholders and Bind Values" section.

        — Ken

Re^2: Perl DBI update tables
by cbtshare (Monk) on Dec 07, 2016 at 01:16 UTC
    I meant to show that but forgot to post the info:
    my $activate_info= $dbh->prepare("SELECT source_code, stream_code, cli +ent_id, name, url, status_code, stream_data, feed_db, feed_table, las +t_update, report_db, sla, exclude_request, owned, push FROM stream WH +ERE id = ?"); $activate_info->execute($client_ID);

      Why are you selecting (and including in the to-insert array) the 3 variables that you have already inserted constants for in the insert statement (client_id, status_code, and feed_db) ?

      as kcott has pointed out you have 12 "?" symbols, so you need 12 members in the to-insert array

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-23 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found