> -----Original Message-----
> From: Frank Newland [mailto:[EMAIL PROTECTED]] 
> Sent: Monday, July 30, 2001 11:35 AM
> To: [EMAIL PROTECTED]
> Subject: Destroying Database Handle
> 
> 
> Question about DBI
> 
> I'm having success in preparing , executing and getting SQL 
> output when I use DBI. What I want to do is ensure that I 
> close properly. 
> Q: What statement(s) do I need to prevent destroying database handle?
> 
> Thanks,
> 
> Frank
> ***************************
> #!/usr/bin/perl -w 
> use strict ;
> use DBI;
> my $dbh ; my $sth ; my $sql_stmt ; $data_row; 
> 
> $dbh = DBI->connect("dbi:Oracle:oracle:qa_1",user, 
> password,{PrintError =>0, AutoCommit =>0 )) || die "failed to 
> login to Oracle \n"; $sql_stmt = << "EOF+" ; select comments 
> from table_a where comments is not null
> EOF+ 
> 
> $sth=$dbh->prepare($sql_stmt) || die "Failure to prepare SQL 
> Statement \n" ; $sth->execute || die "Failure to execute SQL 
> \n"; $data_row=$sth->fetchrow_hashref; $comments = 
> $data_row->{COMMENTS};
> 
> print $comments ;
> ******************************************
> Output:
> 185221202202110  ## desired output. .
> Database handle destroyed without explicit disconnect.

You need to use

   $sth->finish;
   $dbh->disconnect;

After you are done reading fetching the data. That should do the trick.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to