cbtshare has asked for the wisdom of the Perl Monks concerning the following question:
Hello All, In production there are two tables Facebook_321 and Facebook_321_ext Facebook_321:
Facebook_321_ext:id_code: 862012249 entry_time: 2016-10-28 23:36:08 parent_id_code: 783924049_861760507288022 author_name: Lia+nik+son author_code: 1294333813357 author_url: https://www.facebook.com/120357 author_image_url: http://graph.facebook.com/17/picture entry_url: https://business.facebook.com/28262849 entry_types: COMMENT status_code: MOD entry_text: +so%2C++it%27s+the+home+team%21 entry_data: false,"can_comment":false} last_update: 0000-00-00 00:00:00 pull_time: 2016-11-16 18:53:40 queue_code: NULL
id_code: 281938224734_10154342971729735 item_name: pull_run_id item_value: 1480804468 item_data: NULL
I have been making queries against a set of tables based on time, but now there are many Facebook_321_ext tables that don't have a time column so I am basically querying the facebook_321 table based on time getting id_codes and storing them.But I am not sure I am doing it correctly, because I am getting an error
DBD::mysql::st fetchrow_array failed: fetch() without execute() at /ho +me/rdscopy.pl line 199. DBD::mysql::st fetchrow_array failed: fetch() without execute() at /ho +me/rdscopy.pl line 199
I dont think I am handling multiple data correctly, can I get some help please? Thank you
#get Id_Codes based on entry time my $feed_table_ext_idcode = $dbh2->prepare("SELECT id_code FROM $fee +d_table WHERE entry_time >= ?"); $feed_table_ext_idcode->execute($time); my $feed_table_ext_results = $dbh2->prepare("SELECT * from $feed_ta +ble_ext WHERE id_code = ?"); while (my @row = $feed_table_ext_idcode->fetchrow_array()) { #print "@row\n"; $feed_table_ext_results->execute(@row); }
My reasoning for the above code is that , there are many id_codes and data returned and I want to store those and insert them into another DB in staging.
So $feed_table_ext_results has the query, then @row will have all the id_code and information I need execute based on each id_code which would be done by $feed_table_ext_results->execute(@row);Returned after querying facebook_321_ext table in production and need +to copy them to staging ************************** 24. row *************************** id_code: 281938224734_10154342971729735 item_name: PRE_MOD_Krttime item_value: 1480804542 item_data: NULL *************************** 25. row *************************** id_code: 281gfg154342971729735 item_name: PRE_MOD_SetQueue item_value: UNKNOWN item_data: NULL *************************** 26. row *************************** id_code: 281938224734_101gf29735 item_name: PRE_MOD_SetQueue_time item_value: 1480804587 item_data: NULL *************************** 27. row *************************** id_code: 281938224734_10154342971729735 item_name: PRE_MOD_Textalfggtect item_value: POSITIVE item_data: NULL *************************** 28. row *************************** id_code: 281938224734_10154342971729735 item_name: PRE_MOD_TgfentDetect_time item_value: 1480804573 item_data: NULL *************************** 29. row *************************** id_code: 281938224734_10154342971729735 item_name: pull_run_id item_value: 1480804468 item_data: NULL *************************** 30. row *************************** id_code: 281938224734_10154342971729735 item_name: pugfme item_value: 1480804471 item_data: NULL
My insert statement for staging would be below
my $ext_insert = $dbh3->prepare("INSERT IGNORE INTO $feed_table_ext (i +d_code, item_name, item_value, item_data) VALUES (?, ?, ?, ?)") or di +e $dbh3->errstr; while (my @insert_ext = $feed_table_ext_results->fetchrow_array()) { $ext_insert->exe +cute(@insert_ext) or die $sth_insert->errstr; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl DBI execute statement
by choroba (Cardinal) on Dec 12, 2016 at 10:08 UTC | |
by Tux (Canon) on Dec 12, 2016 at 12:09 UTC | |
by afoken (Chancellor) on Dec 16, 2016 at 20:31 UTC | |
|
Re: Perl DBI execute statement
by Marshall (Canon) on Dec 12, 2016 at 07:30 UTC | |
by cbtshare (Monk) on Dec 12, 2016 at 19:16 UTC | |
by huck (Prior) on Dec 12, 2016 at 20:51 UTC | |
by cbtshare (Monk) on Dec 12, 2016 at 21:45 UTC | |
by poj (Abbot) on Dec 12, 2016 at 19:48 UTC | |
by cbtshare (Monk) on Dec 12, 2016 at 21:20 UTC | |
by poj (Abbot) on Dec 12, 2016 at 21:47 UTC | |
| |
by Marshall (Canon) on Dec 14, 2016 at 20:27 UTC | |
by cbtshare (Monk) on Dec 12, 2016 at 17:41 UTC | |
by Marshall (Canon) on Dec 12, 2016 at 18:47 UTC | |
by cbtshare (Monk) on Dec 12, 2016 at 19:07 UTC | |
by Marshall (Canon) on Dec 14, 2016 at 19:49 UTC | |
|
Re: Perl DBI execute statement
by huck (Prior) on Dec 12, 2016 at 09:07 UTC |