Hi, i have a problem. Code:
#C:\Daten\tr> testdb.pl (Windows Programmaufruf)
#Compilerpragma strict not Error
#Merge DBI-Modul
use strict;
use DBI;
#Attribute f� rDBI->connect(), Unterdr�ckung der automatischen Fehlerbehandlung
(Suppression of the automatic error handling)
my %attr =
(
PrintError => 0, #Keine Ausgabe von Fehlermeldungen �ber warn() (No
expenditure of error messages over warn())
RaiseError => 0, #Keine Fehlerbehandlung durch Aufruf von die() (No
error handling by call of die())
);
#Entferne eventuel vorhandene Protokolldateien (Remove eventuel existing log files)
unlink 'dbitrace.log' if -e 'dbitrace.log';
#Ein String mit Sonderzeichen (a string with special characters)
my $string = "DBA";
#Data Source Name = Parameter f�r Verbindungsaufbau (Parameter for connection
establishment)
#(DBI:Treiber:Datenbank-Name[:Host-Name:Port-Nummer des Datenbankservers])
my ( @row,);
my $dsn = 'DBI:ODBC:TEST2';
#Verbinden mit der SAP DB, �bergabe DSN als Argument, Benutzer mit Password,
Fehlerbehandlung
#connect SAPDB, DSN, User; Passwd, Error Message
my $dbh = DBI->connect( $dsn, 'DBA','DBA', \%attr )
or die "Error connecting to my $dsn: $DBI::errstr \n";
#Konvertierung des einzuf�genden Strings (Conversion of the strings which can be
inserted)
my $quoteString = $dbh->quote( $string );
#Setze den Protokollierungsgrad 4 (h�chste) und rufe prepare() auf (Set the logging
degrees 4 (highest) and call prepare())
DBI->trace(4, 'dbitrace.log' );
doPrepare();
#----------------------------------------------------------------------------------------
#SQL Abfrage zur Ausf�hrung vorbereiten, konvertierte String wird mit eingebaut
#SQL Abfrage ausf�hren
#(SQL inquiry for the execution prepare, converted stringer with inserted SQL inquiry
to implement)
#----------------------------------------------------------------------------------------
sub doPrepare
{
print "Vorbereitung und Ausfuehrung einer Abfrage\n"; #Preparation
and execution of an inquiry
my $sth = $dbh->prepare( "SELECT * FROM TABLES = $quoteString" )
or die "Error preperation: ", $dbh->errstr(), "\n";
# or die "Error preperation to my $dsn: $dbh::errstr \n";
$sth->execute()
or die "Error execute: ", $sth->errstr(), "\n";
return;
}
while ( @row = $sth->fetchrow_array() )
{
print "Datenzeile: @row\n";
}
warn " Error in fetchrow_array(): ", $sth->errstr(), "\n"
if $sth->err();
#----------------------------------------------------------------------------------------
# Abmelden von der Datenbank oder Fehler (Log out from the data base or error)
#----------------------------------------------------------------------------------------
$dbh->disconnect or warn "Error with the connecting: ", $dbh->errstr(), "\n";
exit;
A connection to the data base exists.
It functions however no SQL instruction (ODBC).
What wrong do I make?
mfg thomas
dbitrace.log
Description: dbitrace.log
sqltrace.pct
Description: sqltrace.pct
