cbtshare has asked for the wisdom of the Perl Monks concerning the following question:
I have a small script which uses perl DBI to connect to two databases and transfer content of one table(prod) to another table in another DB(prod).I can connect and select data, but the insert statement doesn't work and I get no errors, help please,.
I am getting data in the variable @array
my $table_results= $dbh2->prepare("SELECT * from $feed_table WHERE ent +ry_time >= $time"); $table_results->execute(); #Prepare insert statement $sth_insert = $dbh3->prepare("INSERT IGNORE INTO $feed_table (id_code, +entry_time,parent_id_code,author_name,author_code,author_url,author_i +mage_url,entry_url,entry_types,status_code,entry_text,entry_data,last +_update,pull_time,queue_code) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? +, ?, ?, ?, ?)") or die $dbh3->errstr; while (my @insert = $table_results->fetchrow_array()) { $sth_insert->execute(@insert) or die $dbh->errstr; #I get no errors }
My data structure looks like the following
Warning: Using a password on the command line interface can be insecur +e. *************************** 1. row *************************** id_code: 10153812429735_10154227424399735 entry_time: 2016-10-24 21:13:32 parent_id_code: 28193we4734_10153815104343735 author_name: Chweweles+Lawevin author_code: 102057rw81019807 author_url: https://www.facebook.com/1020dfdfw81019807 author_image_url: http://graph.facebook.com/102fdf1019807/picture entry_url: https://business.facebook.com/2819gf4734/posts/101gf +g815100339735?comment_id=101db8699735 entry_types: PHOTO COMMENT status_code: MOD entry_text: dfdppe+Lafdvin entry_data: {"is_hidden":false,"can_hide":true,"can_remove":true +,"can_comment":true} last_update: 0000-00-00 00:00:00 pull_time: 2016-11-16 19:07:27 queue_code: NULL
My statement @insert = $table_results->fetchrow_array() does have data, but it doesn't seem to enter it in the DB in staging. If I do a print of @insert, I get :
Use of uninitialized value $insert[14] in join or string at /home/anw/ +rds/rdscopy.pl line 99. 862010910596315 2016-10-28 23:32:50 78i404507 +1669_861799288022 Sally+Hill+Deehan 10154kjip13891 https://www.facebo +ok.com/101o8ukuk9002413891 http://graph.facebook.com/10154o8jkjy41389 +1/picture https://business.facebook.com/2819iukjk734/posts/86176kkjkj +288022?comment_id=862010910596315 REMOTE MENTION COMMENT MOD Go+Cubs% +21 {"is_hidden":false,"can_hide":false,"can_remove":false,"can_commen +t":false} 0000-00-00 00:00:00 2016-11-16 18:53:39 Use of uninitialized value $insert[14] in join or string at /home/aw/r +ds/rdscopy.pl line 99.
I also have tried entering the data manually and it works, so there seems to be an issue with just the insert statement. Is there a way to print the insert statement being issued to the DB with the values so I can see what is being passed? My insert statement is below
mysql -hicuc-staging.czrsyfffvbk.us-west-2.rds.amazonaws.com -uroot -pftrol^16 -e "INSERT INTO sstaging_db.FACEBOOK_table34 (id_code, entry_time, parent_id_code, author_name, author_code, author_url, author_image_url, entry_url, entry_types, status_code, entry_text, entry_data, last_update, pull_time, queue_code) VALUES (\"1013555100339735_101542277569735\", \"2016-10-24 21:13:32\", \"281944734_1015384444339735\", \"Cles Lang\", \"10205451019807\", \"https://www.facebook.com/10205449807\", \"http://graph.facebook.com/1020565651019807/picture\", \"https://business.facebook.com/28193yty4734/posts/10153815100339735?comment_id=1015422888888699735\", \"PHOTO COMMENT\", \"MOD\", \"Ph+Lang\", \"{"is_hidden":false, "can_hide":true, "can_remove":true, "can_comment":true}\", \"0000-00-00 00:00:00\", \"2016-11-16 19:07:27\", NULL)"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl DBI statement
by haukex (Archbishop) on Dec 04, 2016 at 08:13 UTC | |
by cbtshare (Monk) on Dec 04, 2016 at 13:54 UTC | |
|
Re: perl DBI statement
by huck (Prior) on Dec 04, 2016 at 05:02 UTC | |
by cbtshare (Monk) on Dec 04, 2016 at 12:54 UTC | |
by poj (Abbot) on Dec 04, 2016 at 13:32 UTC | |
by cbtshare (Monk) on Dec 04, 2016 at 13:44 UTC | |
by huck (Prior) on Dec 04, 2016 at 15:42 UTC | |
| |
|
Re: perl DBI statement
by choroba (Cardinal) on Dec 04, 2016 at 08:42 UTC | |
by cbtshare (Monk) on Dec 04, 2016 at 13:55 UTC | |
|
Re: perl DBI statement
by Marshall (Canon) on Dec 04, 2016 at 18:33 UTC | |
by cbtshare (Monk) on Dec 04, 2016 at 23:30 UTC | |
|
Re: perl DBI statement
by cbtshare (Monk) on Dec 04, 2016 at 13:53 UTC |