in reply to Re: Perl Interpreter Stopped Working . kernelbase.dll error
in thread Perl Interpreter Stopped Working . kernelbase.dll error

C:\Strawberry\perl\bin>perl -v This is perl 5, version 28, subversion 0 (v5.28.0) built for MSWin32-x +64-multi-t hread DBI ---------------------------------------------------------------------- +--- CPAN: Module::CoreList loaded ok (v5.20180622) (no description) T/TI/TIMB/DBI-1.642.tar.gz C:\Strawberry\perl\site\lib\DBI.pm Installed: 1.642 CPAN: 1.642 up to date DBD::Oracle ---------------------------------------------------------------------- +--- CPAN: Module::CoreList loaded ok (v5.20180622) (no description) Z/ZA/ZARQUON/DBD-Oracle-1.76.tar.gz C:\Strawberry\perl\site\lib\DBD\Oracle.pm Installed: 1.76 CPAN: 1.76 up to date The code i am using is as below #!/usr/bin/perl use DBI; use DBD::Oracle; # connect to MySQL... $driver= "Oracle"; #$dsn = "DBI:$driver:ORCL;database=XXX;host=XXX:1521"; $dsn = "DBI:$driver:sid=XXX;host=XXX"; try: $dbh = DBI->connect($dsn, "uname", "pwd"); #prepare and execute the SQL statement $sth = $dbh->prepare("SELECT column FROM table WHERE TP_ID='X'"); $sth->execute; $sth->finish(); except: print "yes"; exit;

Discipulus added code tags March 5 2019

Replies are listed 'Best First'.
Re^3: Perl Interpreter Stopped Working . kernelbase.dll error
by marto (Cardinal) on Mar 05, 2019 at 10:34 UTC

    SELECT column FROM is invalid because column is a reserved word in Oracle. Your code lacks:

    use strict; use warnings;

    You should get in the habit of adding this and defining your variables.

    try: $dbh = DBI->connect($dsn, "uname", "pwd"); #prepare and execute the SQL statement $sth = $dbh->prepare("SELECT column FROM table WHERE TP_ID='X'"); $sth->execute; $sth->finish(); except:

    It looks like you're mixing Python code (try:, except:) with your perl here. See DBI -> RaiseError, Try::Tiny.

      Thanks for the suggestion

      The below code worked fine for me !

      #!/usr/bin/perl use strict; use warnings; use DBI; #use DBD::ODBC; my @row; my $user = 'XXXX'; my $password = 'XXX'; my $dbh = DBI->connect("dbi:Oracle:host=XXX;sid=XXX", $user, $password +);
      Thanks :)