Leser: 22
1 2 3 4 5 6 7 8 9
my $db_source = "dbi:Oracle(AutoCommit=>1):" .$proddbname; my $dbh = DBI->connect( $db_source, $proddbuser, $proddbpasswd ) or die "Keine Datenbankverbindung zu $db_source:\n$DBI::errstr"; foreach(@partnumbers) { $partnr = $_; chomp($partnr); $sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (id=\'$partnr\')'); }
1 2
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (id=?)'); $sth->execute($partnr);
1
2
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (id=\'$partnr\')');
}
1
2
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where id=?');
$sth->execute($partnr);
... or die $DBI::errstr
Guest Hannahab ich schon --> in dem Array stehen die richtigen Werte.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
my $db_source = "dbi:Oracle(AutoCommit=>1):" .$proddbname; my $dbh = DBI->connect( $db_source, $proddbuser, $proddbpasswd ) or die "Keine Datenbankverbindung zu $db_source:\n$DBI::errstr"; foreach(@partnumbers) { $partnr = $_; chomp($partnr); print Dumper $partnr; $sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb WHERE (id= ?)'); # $sth->bind_param(1,$partnr); $sth->execute(); if ( @row = $sth->fetchrow_array ) { print "@row gefunden.\n"; }
Guest Hannaforeach(@partnumbers) {
$partnr = $_;
chomp($partnr);
print Dumper $partnr;
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb WHERE (id= ?)');
# $sth->bind_param(1,$partnr);
$sth->execute();
2009-09-23T14:01:21 pqbitte kürz doch deine zitate moglichst auf das notwendigste. durch die struktur ist eh klar, auf welches posting du dich beziehst. in dem fall hätte der betroffene code-schnipsel gereicht.
danke.
1
2
3
4
use Data::Dumper;
local $Data::Dumper::Useqq = 1;
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (id= ?)');
$sth->execute($partnr);
1 2 3 4
$partnr = '10.0206-0412.4'; print Dumper $partnr; $sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (product_id=?)'); $sth->execute($partnr);
2009-09-23T14:31:28 pqdann scheint das DBD::Oracle nicht zu können.
1 2
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (product_id=?)') or die $dbh->errstr; $sth->execute($partnr) or die $dbh->errstr;
1
2
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (product_id=10)');
$sth->execute();
1
2
3
my $id = 10;
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (product_id=?)');
$sth->execute($id);
2009-09-23T15:05:40 sid burnSoetwas liefert dir also ergebnisse?
Code: (dl )1
2$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (product_id=10)');
$sth->execute();
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (product_id=\'10\')');
Quoteund soetwas nicht?
Code: (dl )1
2
3my $id = 10;
$sth = $dbh->prepare('SELECT PRODUCT_ID FROM schema.products@dblink_to_testdb where (product_id=?)');
$sth->execute($id);
QuoteThe other database need not be an Oracle Database system.
1
2
3
my $id = $dbh->quote(10);
$sth = $dbh->prepare("SELECT PRODUCT_ID FROM schema.products\@dblink_to_testdb where (product_id=$id)");
$sth->execute($id);
where (product_id='$id')
1
2
3
my $stmt = sprintf 'SELECT * FROM asd WHERE id = %s', $dbh->quote($id);
my $sth = $dbh->prepare($stmt);
$sth->execute();