1

I have tried the following script to connect to the DB. This way works in oracle,but i am not sure why it is not working for Sybase.

#!/usr/bin/perl

use strict;
use warnings;

my $result = qx { isql -Uxx -Pxxxxxxx -Dxxxxx <<EOF
select count(*) from XXX;
exit;
EOF
};
print "result is :";
print $result;
print "\nbye bye\n";

I tried to connect to sybase DB without DBI. Please dont tell me to use DBI.even i have know that we can use DBI for this.but unfortunately DBI is not installed here in my server and i am not the admin where i have a authorization to install modules for perl.what ever given to me i have to fully use it. but thats an off topic here.

I repeat the question:

how to connect to sybase DB from perl without using DBI?

The output of the above script is :

> temp.pl
result is :
bye bye

when i manually execute the same thing:

> isql -Uxx -Pxxxxxxxx -Dxxxxx
1> select count(*) from XXX
2> go

 ----------- 
          26 

(1 row affected)
1> exit
>
Vijay
  • 65,327
  • 90
  • 227
  • 319
  • is it exactly what you typed? it should work. what if you execute the same command in an interactive shell? Are PATH LD_LIBRARY_PATH environment exported? – Nahuel Fouilleul Aug 16 '12 at 07:23
  • 1
    No need to be admin to install perl modules http://stackoverflow.com/questions/251705/how-can-i-use-a-new-perl-module-without-install-permissions – Nahuel Fouilleul Aug 16 '12 at 07:28
  • But what is wrong with the abobe code of mine? – Vijay Aug 16 '12 at 07:33
  • Even if we are allowed to install the modules then the script would work only locally.if we have to deliver the script to some one then it would be a problem.So please again donot go back to the same thing of installing modules. – Vijay Aug 16 '12 at 07:39

1 Answers1

0

I got the solution: it is because of the semicolon and the go statement.I modified the script as below and its working now.

#!/usr/bin/perl

use strict;
use warnings;

my $result = qx { isql -Uxx -Pxxxxxxx -Dxxxx <<EOF
set nocount on
select count(*) from XXX
go
exit
EOF
};
print "result is :";
print $result;
print "\nbye bye\n";
Vijay
  • 65,327
  • 90
  • 227
  • 319