Hello,
I try to use Perl and ADO to process database.
Here is my script
(Note that the database has only one record with system settings.)
When I enter the new value of AKTSALDDAT, to update both fields by calling
I get this error /Win32::OLE->LastError()/
What's going wrong? Why Update method is not supported?
There must be something Perl-specific, because when I use similar Python-script, with the same connection string and the same RecordSet filling $RS->Open($sql, $Conn, 1, 3) updating record works.
Can anybody help me?
I try to use Perl and ADO to process database.
Here is my script
Code:
###################################
# Changing the value of AKTSALDDAT
###################################
### Login Data
$csebk = 'AS_400';
$userid= 'user';
$pwd = 'pass';
### using ADO
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
# Create a new Connection
$Conn = Win32::OLE->new("ADODB.Connection");
$RS = Win32::OLE->new("ADODB.Recordset");
# Connection String
$DSN="PROVIDER=IBMDA400;DATA SOURCE=$csebk; USER ID=$userid; PASSWORD=$pwd";
#print "$DSN\n";
$Conn->Open($DSN);
$sql="SELECT * FROM r000100T.r000270V";
$RS->Open($sql, $Conn, 1, 3);
#get the fields
$aktsalddat=$RS->Fields->Item('AKTSALDDAT')->Value;
$ltzsalddat=$RS->Fields->Item('LTZSALDDAT')->Value;
print "\n";
print "Current values:\n";
print "----------------\n";
print "AKTSALDDAT : $aktsalddat\n";
print "LTZSALDDAT : $ltzsalddat\n";
print "\n";
print "New value of AKTSALDDAT : ";
$neuaktsalddat= <STDIN>;
chomp($neuaktsalddat);
if ($neuaktsalddat ne '') {
# update fields
$fields = ["AKTSALDDAT","LTZSALDDAT"];
$values = [$neuaktsalddat,$aktsalddat];
$RS->Update($fields,$values);
if (Win32::OLE->LastError()){
print Win32::OLE->LastError(), "\n";
}
else{
print "AKTSALDDAT was changed !\n";
print "\n";
print "New values are:\n";
print "---------------- \n";
print "AKTSALDDAT : $neuaktsalddat\n";
print "LTZSALDDAT : $aktsalddat\n";
}
}
else {
print "AKTSALDDAT was not changed !\n";
}
# Close Recordset
$RS->Close;
# Close connection
$Conn->Close;
When I enter the new value of AKTSALDDAT, to update both fields by calling
Code:
$RS->Update($fields,$values);
Code:
OLE exception from "Provider":
Method is not supported by this provider.
Win32::OLE(0.1707) error 0x80040e53
in METHOD/PROPERTYGET "Update"
There must be something Perl-specific, because when I use similar Python-script, with the same connection string and the same RecordSet filling $RS->Open($sql, $Conn, 1, 3) updating record works.
Can anybody help me?