的安装包。
2, 从
http://mirrors.sohu.com/CPAN/authors/id/M/MJ/MJEVANS/DBD-ODBC-1.39.t
ar.gz 下载DBD-ODBC-1.39。
3, 安装perl-5.14。perl 默认安装在/opt/ActivePerl-5.14 目录下。
4, 安装DBD-ODBC-1.39,先解压DBD-ODBC-1.39.tar.gz,然后执行如下
命令安装:
/opt/ActivePerl-5.14/bin/perl Makefile.PL
GBase 8a 程序员手册ODBC 篇
南大通用数据技术股份有限公司
- 81 -
make
make install
5, 接下来是创建ODBC 数据源,
创建ODBC 数据源的方法请参考3.2.2。
如
果涉及到中文,那么一定要设置GBase 8a ODBC 驱动的字符集(该字符集需要
与集群安装时默认的字符集保持一致)
。此用例中GBase 8a ODBC 字符集设置为
UTF8。
#!/opt/ActivePerl-5.14/bin/perl
use DBI;
use encoding 'utf-8';
$dbh=DBI->connect('dbi:ODBC:gbase8a', 'gbase', 'gbase20110531');
my $sth=$dbh->prepare("drop table if exists t_plodbc");
$sth->execute();
my $sth=$dbh->prepare("create table t_plodbc(a varchar(100), b
int)");
$sth->execute();
my $sth=$dbh->prepare("insert into t_plodbc values('南大通用',
10)");
$sth->execute();
my $sth=$dbh->prepare("select * from t_plodbc");
$sth->execute();
while(@data=$sth->fetchrow_array())
{
print "$data[0]\n";
}