Leser: 19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
my $fetch = $db->prepare("SELECT [zeit] FROM [doro].[dbo].[meldung] WHERE [fahrer_id]='1899';"); $fetch->execute(); my ($zeitstempel) = $fetch->fetchrow_array(); print "\n\nZeit:$zeitstempel"; sleep (1); my $data = 'XYZ'; my ($id) = $db->selectrow_array("INSERT INTO [doro].[dbo].[system] ([bezeichnung]) VALUES('$data'); SELECT SCOPE_IDENTITY();"); print "\n\nZu suchende id:$id"; sleep (1); my ($test2) = $db->selectrow_array("SELECT * FROM [doro].[dbo].[system] WHERE [id] = '$id';"); print "\n\nGefundene id:$id";
$db->errstr
1
2
3
DBD::ODBC::db selectrow_array failed: [Microsoft][ODBC SQL Server Driver]
Die Verbindung ist mit Ergebnissen von einem anderen hstmt belegt
(SQL-HY000) at MSSQL_connection_test.pl line 60, <DATA> line 164.
1
2
3
4
5
6
sub test05 {
my $fetch = $db->prepare("SELECT [kommtzeit] FROM [dau].[dbo].[meldung] WHERE [fehlercode_id]='1899';");
$fetch->execute();
my ($zeitstempel) = $fetch->fetchrow_array();
print "\n\nKommtzeit:$zeitstempel";
}
1
2
3
4
5
6
7
8
sub test06 {
my $data = 'ZYX';
my $test;
($id) = $db->selectrow_array("INSERT INTO [dau].[dbo].[subsystem] ([bezeichnung]) VALUES('$data'); SELECT SCOPE_IDENTITY();")
or die "\nFehler: id konnte nicht angelegt werden:" . $db->errstr;
print "\n\nid angelegt:$id";
}
$fetch->finish()
QuoteWhen all the data has been fetched from a "SELECT" statement, the driver should automatically call "finish" for you. So you should
not normally need to call it explicitly except when you know that you’ve not fetched all the data from a statement handle. The most
common example is when you only want to fetch one row, but in that case the "selectrow_*" methods are usually better anyway. Adding
calls to "finish" after each fetch loop is a common mistake, don’t do it, it can mask genuine problems like uncaught fetch errors.