Leser: 1
|< 1 2 >| | 13 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
sub db_function {
my $dbh = shift;
my $str = shift;
$sql = "SELECT *.... where blablabla = '$str'";
my $sth = $dbh->prepare($sql) or die 'Fehler:', $DBI::errstr, "\n";
$sth->execute();
# wird der Status 1 oder 0 in $result gespeichert
my $result = $sth->fetchrow_array();
# oder alles in einem Array speichern
# my @result = $sth->fetchrow_array();
return $result;
}
$dbh = DBI->connect("dbi:Oracle:$db_name",$db_username,$db_password, \%attr) or die "Fehler beim Datenbankconnect: $DBI::errstr";
my $db_result = db_function($dbh,$string);
print "$db_result\n";
$dbh->disconnect();
1
2
3
4
5
my $str = shift;
my $sql = "SELECT *.... where blablabla = ?";
my $sth = $dbh->prepare($sql) or die 'Fehler: $DBI::errstr\n";
$sth->execute($str);
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
@driver_names = DBI->available_drivers;
@data_sources = DBI->data_sources($driver_name, \%attr);
$dbh = DBI->connect($data_source, $username, $auth, \%attr);
$rv = $dbh->do($statement);
$rv = $dbh->do($statement, \%attr);
$rv = $dbh->do($statement, \%attr, @bind_values);
$ary_ref = $dbh->selectall_arrayref($statement);
$hash_ref = $dbh->selectall_hashref($statement, $key_field);
$ary_ref = $dbh->selectcol_arrayref($statement);
$ary_ref = $dbh->selectcol_arrayref($statement, \%attr);
@row_ary = $dbh->selectrow_array($statement);
$ary_ref = $dbh->selectrow_arrayref($statement);
$hash_ref = $dbh->selectrow_hashref($statement);
$sth = $dbh->prepare($statement);
$sth = $dbh->prepare_cached($statement);
$rc = $sth->bind_param($p_num, $bind_value);
$rc = $sth->bind_param($p_num, $bind_value, $bind_type);
$rc = $sth->bind_param($p_num, $bind_value, \%attr);
$rv = $sth->execute;
$rv = $sth->execute(@bind_values);
$rc = $sth->bind_param_array($p_num, $bind_values, \%attr);
$rv = $sth->execute_array(\%attr);
$rv = $sth->execute_array(\%attr, @bind_values);
$rc = $sth->bind_col($col_num, \$col_variable);
$rc = $sth->bind_columns(@list_of_refs_to_vars_to_bind);
@row_ary = $sth->fetchrow_array;
$ary_ref = $sth->fetchrow_arrayref;
$hash_ref = $sth->fetchrow_hashref;
$ary_ref = $sth->fetchall_arrayref;
$ary_ref = $sth->fetchall_arrayref( $slice, $max_rows );
1
2
3
4
5
my $str = shift;
my $sql = "SELECT *.... where blablabla = ?";
my $sth = $dbh->prepare($sql) or die 'Fehler: $DBI::errstr\n";
$sth->execute();
1
2
3
4
my $sth = $dbh->prepare( $sql )
or die "Error in preparing SQL: $DBI::errstr\nSQL: $sql\n\n";
$sth->execute( @placeholders )
or die "Error in executing SQL: ", $sth->errstr, "\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
use Data::Dumper;
my $placeHolder1 = 20;
my $sql = 'SELECT *.... where blablabla = ?';
my $sth = $dbh->prepare( $sql )
or die "Error in preparing SQL: $DBI::errstr\nSQL: $sql\n\n";
$sth->execute( $placeHolder1 )
or die "Error in executing SQL: ", $sth->errstr, "\n";
while( my $data = $sth->fetchrow_hashref ) {
print Dumper( $data );
} # while
$sth->finish;
|< 1 2 >| | 13 Einträge, 2 Seiten |