QuotePortable applications should not assume that a new statement can be prepared and/or executed while still fetching results from a previous statement.
1
2
3
4
5
6
7
otobo@21972c404f89:~$ perl nested_prepare.t
deutsch: Österreich
sinhala: ඔස්ට්රියාව
deutsch: Kolumbien
sinhala: කොලොම්බියාව
deutsch: Deutschland
sinhala: ජර්මනිය
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
use v5.24; use strict; use warnings; use utf8; # core modules # CPAN modules use DBI; my $dsn = "DBI:mysql:database=otobo;host=db"; my $dbh = DBI->connect($dsn, 'otobo', 'otobo-docker-databasepw'); $dbh->do( <<'END_SQL' ); CREATE TABLE test_countries ( country_en VARCHAR(100), country_de VARCHAR(100), country_si VARCHAR(100) ); END_SQL # country translations, sorted by the English name my @Countries = ( [ 'Austria', 'Österreich', 'ඔස්ට්රියාව', 1 ], [ 'Colombia', 'Kolumbien', 'කොලොම්බියාව', 1 ], [ 'Germany', 'Deutschland', 'ජර්මනිය', 1 ], ); for my $Country ( @Countries ) { $dbh->do( "INSERT INTO test_countries ( country_en, country_de, country_si ) VALUES (?, ?, ? )", undef, $Country->@*, ); } my $sel_outer_sth = $dbh->prepare( "SELECT country_de FROM test_countries" ); $sel_outer_sth->execute; while ( my ($country_de) = $sel_outer_sth->fetchrow_array ) { say "deutsch: $country_de"; my $sel_inner_sth = $dbh->prepare( "SELECT country_si FROM test_countries WHERE country_de = ?" ); $sel_inner_sth->execute($country_de); while ( my ($country_si) = $sel_inner_sth->fetchrow_array ) { say "sinhala: $country_si"; } } $dbh->do( 'DROP TABLE test_countries' );
QuotePortable applications should not assume that a new statement can be
prepared and/or executed while still fetching results from a previous
statement.
2023-10-19T09:33:40 rostiDann bist du in der Handwerksrolle eingetragen?Programmieren ist ein praktisches Handwerk.
2023-10-20T07:30:11 GwenDragonUnd es ist auch eine künstlerische Tätigkeit.
1 2 3 4 5
[ {de => 'Deutschland', en => 'Germany', si => 'ජර්මනිය'}, {de => 'Österreich', en => 'Austria', si => 'ඔස්ට්රියාව'}, {de => 'Kolumbien', en => 'Columbia', si => 'කොලොම්බියාව'} ]