
nagalenoj
Novice
Nov 14, 2008, 6:36 AM
Post #1 of 4
(6330 views)
|
Here, what is the use of finish() ?
|
Can't Post
|
|
Dear friends, sub read_config { # connecting to the database my $dsn = "DBI:Pg:database=nagalenoj"; my $conf_dbh = DBI->connect($dsn, "nagalenoj", "nagalenoj", {RaiseError => 0}) or new_log("$0: Error while databse connection") and exit(1); # query to execute. my $statement = $conf_dbh->prepare("select * from dbi.free_conf"); # select the first row from the table, since we can have only one configuration data, it's enough to read only the first row. So, if the table has more than a row, the row won't be considered. $statement->execute(); $statement->bind_columns(\$options, \$interval, \$keep_records, \$rec_category, \$logfile, \$cont_if_exist); $statement->fetch(); #revert back. $statement->finish(); ## commented out for checking. new_log ("Configurations:options-$options,interval-$interval,keep_record-$keep_records,record_category-$rec_category,logfile-$logfile,cont_if_exist-$cont_if_exist"); #disconnecting the database connection #$conf_dbh->DESTROY(); $conf_dbh->disconnect; } In the above coding, I am reading a configuration table and I assigned in some variables. The configuration table is having only one row. So, I am fetching that one row and I did the disconnect. But, It shows an error that I have to use the finish() to end the statement. After adding the call to finish() function, the program is working without errors. So, Can anyone tell me the use of finish() function.
|