如何从Perl访问Oracle数据库? [英] How to access an Oracle database from Perl?

查看:165
本文介绍了如何从Perl访问Oracle数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一些shell脚本转换为perl.所有数据库访问均使用sqlplus完成.使用perl是访问Oracle数据库的更好方法,或者我应该坚持使用sqlplus.

I'm converting some shell scripts to perl. All the database access is done using sqlplus. With perl is that a better way to access an Oracle database or should I just stick to sqlplus.

推荐答案

以下是使用DBI的简短示例:

Here is a short example of usage of DBI:

use DBI;

$user = 'donny';
$password = 'ppp';
$dbconnectstring = 'basetest';
$dbh = DBI->connect('dbi:Oracle:',$user.'@'.$password,$dbconnectstring);

此外,请注意,您可以在perl脚本中访问sqlplus-或任何命令行.只需使用反引号即可:

Also, note you can access sqlplus - or any command line - within a perl script. Just use backticks:

`cd dasd`

例如.不确定您是否要这样做,只是一个想法,因为您说过要将shell转换为perl.

For example. Not sure if you'd want to do this, but just an idea, since you said you're converting shell to perl.

这篇关于如何从Perl访问Oracle数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆