I am copying data from table 1 and insert into table 2, the issue is I don't want to insert all the data I received from table 1 value for value, I want to update some fields and leave other fields to auto increment

Table structure is id int(11) source_code varchar(20) stream_code char(100) client_id int(11) stream_oauth_id int(11) name varchar(200) url varchar(2500) status_code char(10) stream_data longtext feed_db varchar(500) feed_table varchar(200) last_update datetime report_db varchar(500) sla smallint(5) unsigned exclude_request varchar(200) owned tinyint(1) push tinyint(1) unsigned

The table information is

id: 447 source_code: FACEBOOK stream_code: 281434322dd4734 client_id: 53 stream_oauth_id: 422 name: Seer url: Old Beer status_code: DISABLED stream_data: NULL feed_db: production_feed002 feed_table: FACEBOOK_28111aa734 last_update: 2015-02-05 13:23:19 report_db: production_report002 sla: 0 exclude_request: CONVERSATIONS owned: 1 push: 0

My insert statement is below so I am not updating all the values, is this a problem? The error I am getting is below, I am not sure why are there 12 values needed
DBD::mysql::st execute failed: called with 15 bind variables when 12 are needed at /home/rdscopy.pl line 131. DBD::mysql::st execute failed: called with 15 bind variables when 12 are needed at /home/rdscopy.pl line 131.

$activate_stream =$dbh4->prepare("INSERT INTO stream (source_code, str +eam_code, client_id, name, url, status_code, stream_data, feed_db, fe +ed_table, last_update, report_db, sla, exclude_request, owned, push) +VALUES(?, ?, 10, ?, ?, DISABLED, ?, production_feed002, ?, ?, ?, ?, ? +, ?, ?)"); while (my @activate_results = $activate_info >fetchrow_array() ) + { + $activate_stream->execute(@activate_results) or die $activate_strea +m->errstr; + } } $activate_stream->finish();

id is an auto-increment so we let MySQL assign a value
I want to make client id = 10.
Skip the stream_oauth_id for now. That should get created if/when we refresh access tokens on the stream. It may not be necessary in most test cases.
feed_db will be also assigned in the insert statement


In reply to Perl DBI update tables by cbtshare

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.