10 Einträge, 1 Seite |
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#! perl
use Sybase::Sybperl;
use Sybase::DBlib;
dbmsghandle ("message_handler");
dberrhandle ("error_handler");
my $user= "";
my $pass= "";
my $server= "";
my $db = "";
my $dbh = 0;
my @data;
my @rueck;
my $status = "";
my $sql = " Select * from Test ";
open(LOGG,">>x.test");
print LOGG "\n LOGG".log_time()."opend";
$dbh = new Sybase::DBlib $user,$pass;
print LOGG "\n LOGG".log_time()."Connected";
$dbh->dbuse($db);
print LOGG "\n LOGG".log_time()."DB changed";
$status = $dbh->dbcmd($sql);
print LOGG "\n LOGG".log_time()."sql";
$status = $dbh->dbsqlexec;
print LOGG "\n LOGG".log_time()."executed";
$status=$dbh->dbresults;
print LOGG "\n LOGG".log_time()."results";
while(@data = $dbh->dbnextrow)
{
if(@rueck==0)
{
@rueck=[@data];
}
else
{
push(@rueck,[@data]);
}
}
$sql = "select * from tet";
$status = $dbh->dbcmd($sql);
print LOGG "\n LOGG".log_time()."sql";
$status = $dbh->dbsqlexec;
print LOGG "\n LOGG".log_time()."executed";
$status=$dbh->dbresults;
print LOGG "\n LOGG".log_time()."results";
$dbh->dbclose;
print LOGG "\n LOGG".log_time()."DB closed";
foreach (@rueck)
{
print "\n ". $_;
}
close(LOGG);
#=============================================================
#=============================================================
# Sybperl Error-Handling
#=============================================================
sub message_handler
{
my ($db, $message, $state, $severity, $text, $server, $procedure,$line) = @_;
if ($severity > 10)
{
print LOGG "\n !FAIL".log_time()."Sybase message ". $message .", Severity ". $severity .", state ". $state;
print LOGG "\n !FAIL".log_time()."Server `". $server. "'" if defined ($server);
print LOGG "\n !FAIL".log_time()."Procedure `". $procedure. "'" if defined ($procedure);
print LOGG "\n !FAIL".log_time()."Line ". $line if defined ($line);
print LOGG "\n !FAIL".log_time().$text. "\n\n";
# &dbstrcpy returns the command buffer.
if(defined($db))
{
my ($lineno, $cmdbuff) = (1, undef);
my $row;
$cmdbuff = &Sybase::DBlib::dbstrcpy($db);
foreach $row (split (/\n/, $cmdbuff))
{
print LOGG "\n !FAIL".log_time(). sprintf ("%5d", $lineno ++). "> ". $row, "\n";
}
}
}
elsif ($message == 0)
{
print LOGG "\n !FAIL".log_time(). $text;
}
return 1;
}
sub error_handler
{
my ($db, $severity, $error, $os_error, $error_msg, $os_error_msg)= @_;
# Check the error code to see if we should report this.
if ($error != SYBESMSG)
{
print LOGG "\n !FAIL".log_time()."Sybase error: ", $error_msg;
print LOGG "\n !FAIL".log_time()."OS Error: ", $os_error_msg if defined ($os_error_msg);
}
return 0;
}
return 1;
10 Einträge, 1 Seite |