Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > isql in perl

Reply
Thread Tools

isql in perl

 
 
mike
Guest
Posts: n/a
 
      12-26-2003
hi

i have a code like this

open ISQL, "| isql -U $user -S $server " or die "Failed to open: $!";
print ISQL << "EOF";
select count(*) from table
go
quit
EOF

this code is suppose to get the count from a table in my database.
how can i assign this count to a perl variable??
thanks...
 
Reply With Quote
 
 
 
 
Gregory Toomey
Guest
Posts: n/a
 
      12-26-2003
It was a dark and stormy night, and mike managed to scribble:

> hi
>
> i have a code like this
>
> open ISQL, "| isql -U $user -S $server " or die "Failed to open: $!";
> print ISQL << "EOF";
> select count(*) from table
> go
> quit
> EOF
>
> this code is suppose to get the count from a table in my database.
> how can i assign this count to a perl variable??
> thanks...


Use Perl dbi instead http://dbi.perl.org/

gtoomey
 
Reply With Quote
 
 
 
 
mike
Guest
Posts: n/a
 
      12-27-2003
Gregory Toomey <(E-Mail Removed)> wrote in message news:<1080562.d8XGKOZNtQ@gregs-web-hosting-and-pickle-farming>...
> It was a dark and stormy night, and mike managed to scribble:
>
> > hi
> >
> > i have a code like this
> >
> > open ISQL, "| isql -U $user -S $server " or die "Failed to open: $!";
> > print ISQL << "EOF";
> > select count(*) from table
> > go
> > quit
> > EOF
> >
> > this code is suppose to get the count from a table in my database.
> > how can i assign this count to a perl variable??
> > thanks...

>
> Use Perl dbi instead http://dbi.perl.org/
>
> gtoomey



hi
i do not have the facility(compiler) to compile DBI module on my Solaris machine
so that's why i have to use the isql client for access to database...
cheers
 
Reply With Quote
 
Nicholas Dronen
Guest
Posts: n/a
 
      12-27-2003
mike <(E-Mail Removed)> wrote:

[ snip ]

m> open ISQL, "| isql -U $user -S $server " or die "Failed to open: $!";
m> print ISQL << "EOF";
m> select count(*) from table
m> go
m> quit
m> EOF

m> this code is suppose to get the count from a table in my database.
m> how can i assign this count to a perl variable??

You can always read

$ perldoc -q pipe

but I'd just install gcc from

http://www.sunfreeware.com/

and install and use DBI as the other poster suggested.

Regards,

Nicholas

--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      12-29-2003
On 26 Dec 2003 18:35:50 -0800
http://www.velocityreviews.com/forums/(E-Mail Removed) (mike) wrote:
> Gregory Toomey <(E-Mail Removed)> wrote in message
> news:<1080562.d8XGKOZNtQ@gregs-web-hosting-and-pickle-farming>...
> > > i have a code like this
> > >
> > > open ISQL, "| isql -U $user -S $server " or die "Failed to open:
> > > $!"; print ISQL << "EOF";
> > > select count(*) from table
> > > go
> > > quit
> > > EOF
> > >
> > > this code is suppose to get the count from a table in my
> > > database. how can i assign this count to a perl variable??
> > > thanks...

> >
> > Use Perl dbi instead http://dbi.perl.org/

>
> i do not have the facility(compiler) to compile DBI module on my
> Solaris machine so that's why i have to use the isql client for
> access to database... cheers


What does this statement mean? You don't have 'root' access? No
access to a complier? ??

To get information the way you posted, you could do it from any shell.
Just redirect the output of the 'isql' command to a file and do
something with the file. If you don't want to do that, then use DBI
(which is more idiomatic Perl).

Pretty simple.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
VYARZERZOMANIMORORSEZASSEZANSERAREORSES?

 
Reply With Quote
 
Ragnar Hafstaš
Guest
Posts: n/a
 
      12-29-2003
"James Willmore" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) phia.net...
snipped problem with database access without DBI

>
> To get information the way you posted, you could do it from any shell.
> Just redirect the output of the 'isql' command to a file and do
> something with the file.


I have been that road, and it leads to madness

seriously, try to avoid this if you at all can.
apart from the headaches parsing the output and grabbing errors,
the performance will take a real hit.

gnari




 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      12-29-2003
On Mon, 29 Dec 2003 16:33:57 -0000
"Ragnar Hafstaš" <(E-Mail Removed)> wrote:

> "James Willmore" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) phia.net...
> snipped problem with database access without DBI
>
> >
> > To get information the way you posted, you could do it from any
> > shell.
> > Just redirect the output of the 'isql' command to a file and do
> > something with the file.

>
> I have been that road, and it leads to madness
>
> seriously, try to avoid this if you at all can.
> apart from the headaches parsing the output and grabbing errors,
> the performance will take a real hit.


I agree However, the OP stated he could not use a compiler, which
I don't understand. I (and others) have installed various modules
without 'root' access with no problem. He may have other issues (like
no compiler - which is very hard to believe for a *NIX platform like
Solaris).

To each his own - I'd use DBI - he may not

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Meeting, n.: An assembly of people coming together to decide
what person or department not represented in the room must solve
a problem.
 
Reply With Quote
 
Keith Keller
Guest
Posts: n/a
 
      12-29-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2003-12-29, James Willmore <(E-Mail Removed)> wrote:
>
> I agree However, the OP stated he could not use a compiler, which
> I don't understand.


Not all boxes have a compiler installed. The OP's system may be one of
them, and he may not have the disk space to install his own.

> He may have other issues (like
> no compiler - which is very hard to believe for a *NIX platform like
> Solaris).


It may be that the sysadmin was told to remove compilers to make it more
difficult for employees to install their own software. (I've heard of
places where this is done, though fortunately have never worked for any
of them.)

- --keith

- --
http://www.velocityreviews.com/forums/(E-Mail Removed)-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/8GbohVcNCxZ5ID8RAoCFAJ9tSMX8aO8uh2B/8BQfCwf5M2ryKQCeL6vr
RRmWfeJ/UsS+IKqEytbBs7A=
=eNWZ
-----END PGP SIGNATURE-----
 
Reply With Quote
 
Ragnar Hafstaš
Guest
Posts: n/a
 
      12-29-2003
"Keith Keller" <(E-Mail Removed)-francisco.ca.us> wrote in message
news:(E-Mail Removed)-francisco.ca.us...
>
> It may be that the sysadmin was told to remove compilers to make it more
> difficult for employees to install their own software.


in that case he should ask the sysadmin to install DBI and the correct DBD
module

gnari



 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      12-29-2003
On Mon, 29 Dec 2003 09:40:03 -0800
Keith Keller <(E-Mail Removed)-francisco.ca.us> wrote:

> On 2003-12-29, James Willmore <(E-Mail Removed)> wrote:
> >
> > I agree However, the OP stated he could not use a compiler,
> > which I don't understand.

>
> Not all boxes have a compiler installed. The OP's system may be one
> of them, and he may not have the disk space to install his own.
>
> > He may have other issues (like
> > no compiler - which is very hard to believe for a *NIX platform
> > like Solaris).

>
> It may be that the sysadmin was told to remove compilers to make it
> more difficult for employees to install their own software. (I've
> heard of places where this is done, though fortunately have never
> worked for any of them.)


Good for security - bad for installing DBI

In this instance, what do you do when you need to install something -
use NFS mounts or something else? This *may* help the OP (and I'm one
that always likes to learn something).

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Talk sense to a fool and he calls you foolish. -- Euripides

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
subprocess & isql peterff66 Python 1 07-15-2011 01:54 PM
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 02-03-2011 11:00 AM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 01-23-2011 05:00 AM
how to enumerate a list of sql servers (isql -L like command) in Java! Remi Morin Java 0 10-23-2006 04:15 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments