Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The error message isfor my $sql qw(sakila-schema.sql sakila-data.sql) { my $file = "sakila-db/$sql"; my $contents = read_file($file); print "\t$file\n"; open my $fh, '|-', 'mysql', @opt; print $fh $contents; }
List form of pipe open not implemented at (eval 19) line 109 main::__ANON__('GLOB(0x2f641ec)', '|-', 'mysql', '--user=root', '--password=passw0rd', '--host=localhost', '--port=3306') called at etc/install_sakila.pl line 56
Now, it is not as simple as changing the input record separator to semicolon because certain sections of the file change the SQL delimiter to $$:
DELIMITER $$ CREATE FUNCTION inventory_held_by_customer(p_inventory_id INT) RETURNS + INT READS SQL DATA BEGIN DECLARE v_customer_id INT; DECLARE EXIT HANDLER FOR NOT FOUND RETURN NULL; SELECT customer_id INTO v_customer_id FROM rental WHERE return_date IS NULL AND inventory_id = p_inventory_id; RETURN v_customer_id; END $$ DELIMITER ;
Call mysql SOURCE would've been awesome, but that's only in the MySQL client, not in the server. So it looks like my options are:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Executing a file of SQL commands against MySQL server
by Gangabass (Vicar) on Aug 18, 2011 at 02:50 UTC | |
by Neighbour (Friar) on Aug 18, 2011 at 08:35 UTC | |
by metaperl (Curate) on Aug 18, 2011 at 17:50 UTC | |
|
Re: Executing a file of SQL commands against MySQL server
by juster (Friar) on Aug 18, 2011 at 14:55 UTC |