Perl database connectively

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rag84dec
    New Member
    • Mar 2007
    • 100

    Perl database connectively

    HI,
    i am new to perl and i have installed activeperl
    Now, i want to write some program related to database.
    Can anyone plss tell me wat to install and how to???

    thanks
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    Hi rag84dec,

    Read this: cpan DBI

    - Miller

    Comment

    • rag84dec
      New Member
      • Mar 2007
      • 100

      #3
      i have downloaded DBI.pm ....where to download??...c: \perl\lib???

      Then what next???

      Comment

      • Bsr
        New Member
        • Mar 2007
        • 20

        #4
        Originally posted by rag84dec
        HI,
        i am new to perl and i have installed activeperl
        Now, i want to write some program related to database.
        Can anyone plss tell me wat to install and how to???

        thanks

        Hi,

        After installation Perl, you go for command prompt and give "ppm" at the prompt.then it displays the prompt as ppm>

        Example:1. c:\perl> this is command prompt
        2. c:\perl>ppm
        3. ppm>install DBI (wait some time)
        4. ppm>install DBD-Oracle
        5. ppm>exit (come out from ppm)
        Kindly let me know if you have any issues

        Cheers
        Bhuvan

        Comment

        • miller
          Recognized Expert Top Contributor
          • Oct 2006
          • 1086

          #5
          Hi rag84dec,

          Bhuvan's method will most likely work for you if you're on a windows machine. Find more general information on installing cpan modules here:

          cpanfaq - How do I install Perl modules?

          - Miller

          Comment

          • rag84dec
            New Member
            • Mar 2007
            • 100

            #6
            Thanks Bhuvan and miller....

            I went to command promt and went into ppm
            and typed "install DBI"
            It gave me an error "error installing package 'DBI':could not locate a PPD file for package DBI"

            Please help

            Comment

            • Bsr
              New Member
              • Mar 2007
              • 20

              #7
              Hi,

              I do not have correct answer for that one. But what i am suggesting you first uninstall the Active Perl,restart the your system and again install that Active Perl.Then you install DBI and DBD-Oracle modules.

              Let us know if you have any issues.

              Cheers
              Bhuvan

              Comment

              • rag84dec
                New Member
                • Mar 2007
                • 100

                #8
                I reinstalled the ActivePerl-5.6.1.638-MSWin32-x86.msi.
                Then i downloaded the DBI.zip.
                then i went to ppm in command prompt.and said "ppm install DBI.ppd"
                It got installed.
                I cud see it weh i say "query".It says DBI been installed.

                then i have written a simple program which has use DBI;
                is used nothing else

                #!c:\perl\bin\p erl.exe\
                use DBI;

                is the code.

                but it gives me the error as following..

                DBI object version 1.34 does not match $DBI::VERSION 1.54 at C:/Perl/lib/DynaLoader.pm line 225.
                BEGIN failed--compilation aborted at C:/Perl/lib/DBI.pm line 261.
                Compilation failed in require at C:\Perl\hello.p l line 2.
                BEGIN failed--compilation aborted at C:\Perl\hello.p l line 2.

                Comment

                • Bsr
                  New Member
                  • Mar 2007
                  • 20

                  #9
                  Hi,

                  What is your database name? (Ex:Oracle or SQlServer2005)

                  If Database is Oracle ,you should install DBD-Oracle after installation DBI.

                  Could you please send me your perl code which has written by you.

                  Cheers
                  Bhuvan

                  Comment

                  • rag84dec
                    New Member
                    • Mar 2007
                    • 100

                    #10
                    hi
                    the program is onlu this much

                    #!c:\perl\bin\p erl.exe
                    use DBI;


                    i have microsoft sql server installed
                    Which DBD shud i use??...DBD-sql??

                    give me the location from where i can download....

                    Comment

                    • Bsr
                      New Member
                      • Mar 2007
                      • 20

                      #11
                      Hi,

                      Install "Class-DBI-MSSQL" and try it your code.


                      Please find my sample perl code for retrieve the data from table


                      Code:
                      #!/usr/bin/perl -w
                      
                      use DBI;
                      use warnings;
                      use strict;
                      $ENV{NLS_LANG} = 'AMERICAN_AMERICA.UTF8';
                      my $dbh = DBI->connect ("dbi:Oracle:Enter host name","user name","password") or die "Cant connect to : $DBI::errstr\n";
                      my $sth = $dbh->prepare("SELECT * FROM employee");
                      $sth->execute();
                      while (my @row = $sth->fetchrow_array())
                      {
                      	print "@row\n";
                      	#sleep 1;
                      }
                      
                      $dbh->disconnect();
                      exit;

                      Note:In the above code u should give Hostname,userna me and Password, do not forget to give this one
                      Last edited by miller; Mar 28 '07, 04:50 PM. Reason: Code tag

                      Comment

                      • rag84dec
                        New Member
                        • Mar 2007
                        • 100

                        #12
                        where will i get "make" file??
                        what shud be the sequence of installing DBI and DBDs??

                        I am going thru "http://www.cpan.org/modules/by-module/DBD/DBD-ODBC-1.13.readme"

                        I am getting errors.while installing DBI

                        Please put whole procedure
                        After installing Activeperl...Ho w to install DBI and DBD???

                        Comment

                        • Bsr
                          New Member
                          • Mar 2007
                          • 20

                          #13
                          Hi,

                          1.where will i get "make" file??

                          You download that file and save to your loacal repository system.

                          2.How do Run that Makefile.pl?

                          1.Navigate to that folder which is having this Makefile.pl
                          2.Give the command "Perl Makefile.pl"
                          3.what shud be the sequence of installing DBI and DBDs??

                          First you should install DBI after that install DBD-ODBC and DBD-Oracle.

                          Comment

                          Working...