how to connect to db2 using shell script commands

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srikanths2008
    New Member
    • Nov 2009
    • 1

    how to connect to db2 using shell script commands

    Hi,

    I'm trying to retrieve a record from DB2 without using DBI package like this.
    Code:
    system("db2 select \* from customer where cname=\'steve\' ");
    but it fails everytime with the error. this only happens when using a ' in the condition (such as 'steve' in this example). Using a number works fine.

    Any ideas on how to resolve this is appreciated.
    Last edited by numberwhun; Nov 30 '09, 02:47 PM. Reason: Please use code tags!!!
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    There is no reason to be issueing system() commands in order to access information in a database using Perl.

    You should really be using the DBI module with the DBD::DB2 driver to connect and get whatever information you need to. It is MUCH more efficient than the way you are trying to do it.

    There are plenty of DBI tutorials out there for you to read and learn from.

    Regards,

    Jeff

    Comment

    Working...