Voici un sous-programme :
Est-ce une bonne idée d'utiliser un placeholder dans ce cas là?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 sub UPDATE_DB { my ($acc, $start, $end) = @_; my $sql = "UPDATE $Table SET 28S_start = '$start', 28S_end = '$end' WHERE accession = '$acc'"; print "$sql\n"; my $sth = $dbh->prepare($sql) or print "erreur de preparation SQL \$sql\n"; $sth->execute or die "Could not execute SQL statement ... maybe invalid?\n$sql\n"; $sth->finish; ($start, $end) = (); }
vaut-il mieux passer $sth en argument à chaque appel de la fonction?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 my $sql = <<"SQL2"; UPDATE Samson_28S SET 28S_start = '?', 28S_end = '?' WHERE accession = '?' SQL2 my $sth = $dbh->prepare($sql) or print "erreur de preparation SQL \$sql\n"; foreach my $acc (@request){ ... UPDATE_DB($acc, $start, $end); ... } $sth->finish; $dbh->disconnect(); sub UPDATE_DB { my ($acc, $start, $end) = @_; $sth->execute( $start, $end, $acc; ) ($start, $end) = (); }
Merci pour votre aide.
Partager