Dear all,
I'am new to this list and want to say hello first.
I've written an easy ActiveState Perl script which will read from Novell NDS
(neccessary Novell ODBC Driver installed) and put these records into a MS
Access Database thru ODBC, too.
The first I read the NDS-Users and this works good. Also writing the users
to Access is ok. But when I issue a second SQL statement to Novell NDS to
read all Users my Perl.exe will give me a GUI message that perl.exe is
abending. The killing line is the second FetchRow_Array().
I've also tried to disconnect and connect again->no
I've also tried to read the Groups (the second sql statement) first to see
if the sql statements are ok -> everything fine
I've also commented the first while to see if the second while (second sql
statement) will work if the first fetchrow_array was skipped, but written a
dummy to Access ->ok
I do not want to make several codes to read a table one time...
Does anyone has a hint for me?
Many thanks
Carsten Sch�fer
<<<<<<<<<<<<<<< code fragment >>>>>>>>>>>>>>>>>>>>
############## START ##################
# DBs �ffnen
my $DB = DBI->connect("DBI:ODBC:$DSN");
my $DB2 = DBI->connect("DBI:ODBC:$DSN2");
#### Reading USERS #######
print REP "Reading NDS-Users....\n";
print "Reading NDS-Users and writing them to MigraBase...";
### Prepare a SQL statement for reading the users
my $command = $DB->prepare("SELECT NDS_Name FROM UserNDS") or die "Can't
prepare SQL read statement: DBI::errstr\n";
### Execute the statement in the database
$command->execute or die "Can't execute SQL statement: $DBI::errstr\n";
### Retrieve the returned rows of data (and writing the users to MigraBase)
while(@Data = $command->fetchrow_array())
{
print ".";
$countUsers++;
$NDS_Name = $Data[0];
# Prepare a SQL statement for writing one user a time
# Reason why writing one user one time and not going thru a very laaarge
array: maybe the customers nds is veeeery large...what will happen with my
array??
my $writecommand = $DB2->prepare("INSERT INTO User_old (MatchID_U, NDSName)
VALUES ('$countUsers', '$NDS_Name')") or die "Can't prepare SQL write
statement: $DBI::errstr\n";
$writecommand->execute();
undef $NDS_Name;
}
warn "Data fetching terminated early by error: $DBI::errstr\n" if $DBI::err;
print REP "Reading of NDSUsers and writing to MigraBase done (was counting:
$countUsers Users)\n";
#### Reading GROUPS #######
print REP "Reading NDS-Groups....\n";
print "\nReading NDS-Groups and writing them to MigraBase...";
undef $command;
undef @Data;
### Prepare a SQL statement for reading the groups
$command = $DB->prepare("SELECT NDS_Name FROM GroupNDS") or die "Can't
prepare SQL read statement: $DBI::errstr\n";
### Execute the statement in the database
$command->execute or die "Can't execute SQL statement: $DBI::errstr\n";
### Retrieve the returned rows of data (and writing the users to MigraBase)
while(@Data = $command->fetchrow_array())
{
print ".";
$countGroups++;
$NDS_Name = $Data[0];
# Prepare a SQL statement for writing one group a time
my $writecommand = $DB2->prepare("INSERT INTO Group_old (MatchID_G,
NDSName) VALUES ('$countGroups', '$NDS_Name')") or die "Can't prepare SQL
write statement: $DBI::errstr\n";
$writecommand->execute();
undef $NDS_Name;
}
warn "Data fetching terminated early by error: $DBI::errstr\n" if $DBI::err;
print REP "Reading of NDSGroups and writing to MigraBase done (was counting:
$countGroups Groups)\n";
### Disconnect from the database
$DB->disconnect or warn "Error disconnecting: $DBI::errstr\n";
$DB2->disconnect or warn "Error disconnecting: $DBI::errstr\n";