perl - Why do i get error on prepare? -
class="snippet-code-js lang-js prettyprint-override">#!/usr/bin/perl utilize strict; utilize sybase::dblib; utilize sys::hostname; utilize getopt::std; ## additionals utilize lib "/opt/chsdjg/perllib"; utilize additionals; ($dsn, $database, $dbserver, $dbname, $user, $passwd, $rmdb_config ) = ('','','','','','',''); $dbhandle; $rmdb_config = "$env{env_dir}"; $dsn = "dbi:sybase"; $database = bring together (' ~ ',$dsn, $dbserver, $dbname, $user, $passwd, $rmdb_config); $dbhandle = connect_me($database); $ctl= "select * table_name"; $dbhandle->dbcmd($ctl); $ret = $dbhandle->dbsqlexec; $res = $dbhandle->dbresults; @dat; while($dbhandle->dbresults != no_more_results) { while(@dat = $dbhandle->dbnextrow) { print "@dat\n"; } }
i didnt utilize right connection first time. code now, makes select statement , shows result. hope helps people.
you never create database handle ($dbh undefined).
add
my $dbh = $dbh = dbi->connect($data_source, $username, $password) or die $dbi::errstr;
to code. see documentation on cpan more information.
perl
No comments:
Post a Comment