http://www.perlmonks.org?node_id=687584


in reply to Re: Is bind useful for one-time queries and commands?
in thread Is bind useful for one-time queries and commands?

Dear Friends,
I am very new to perl ,can any one post the sample code for the database operation with bind ?.
Best Regards, S.Sabarinathan,
  • Comment on Re^2: Is bind useful for one-time queries and commands?

Replies are listed 'Best First'.
Re^3: Is bind useful for one-time queries and commands?
by sathiya.sw (Monk) on Nov 19, 2008 at 14:06 UTC
    check the following sample code ( for sabari )..
    #Establish the connection to the database. my $dbh = DBI->connect( 'dbi:Pg:database=test','test','1234',{RaiseErr +or => 1,AutoCommit => 0}) || die "Database connection not made: $DBI::errstr"; #It get the port number and IP address from the data base. my $sql = qq{ SELECT port,ipaddr,log_file FROM details where name='$na +me'}; my $sth = $dbh->prepare( $sql ); $sth->execute(); #bind_columns - It stored the port number and IP address to variable. my( $port, $ipaddr,$log_file ); $sth->bind_columns(\$port, \$ipaddr,\$log_file); #It fetch the values from table $sth->fetch(); $sth->finish(); #Dis-connect the database,if we miss it tells warnings, that destroy h +ad been #called with out disconnect. $dbh->disconnect();