How to access an Oracle database from Perl?

后端 未结 2 603
挽巷
挽巷 2021-01-22 03:22

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

2条回答
  •  自闭症患者
    2021-01-22 03:52

    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);
    

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

    `cd dasd`
    

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

提交回复
热议问题