cbtshare has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl DBI update tables
by kcott (Archbishop) on Dec 07, 2016 at 00:20 UTC | |
by cbtshare (Monk) on Dec 07, 2016 at 04:56 UTC | |
|
Re: Perl DBI update tables
by huck (Prior) on Dec 07, 2016 at 00:22 UTC | |
by kcott (Archbishop) on Dec 07, 2016 at 01:10 UTC | |
by cbtshare (Monk) on Dec 07, 2016 at 01:17 UTC | |
by kcott (Archbishop) on Dec 07, 2016 at 02:43 UTC | |
by cbtshare (Monk) on Dec 07, 2016 at 01:16 UTC | |
by huck (Prior) on Dec 07, 2016 at 04:58 UTC |