isql in perl

M

mike

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...
 
G

Gregory Toomey

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
 
M

mike

Gregory Toomey said:
It was a dark and stormy night, and mike managed to scribble:


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
 
N

Nicholas Dronen

[ 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
 
J

James Willmore

On 26 Dec 2003 18:35:50 -0800
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?
 
R

Ragnar Hafstað

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
 
J

James Willmore

snipped problem with database access without DBI


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.
 
K

Keith Keller

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

- --
(e-mail address 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-----
 
R

Ragnar Hafstað

Keith Keller said:
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
 
J

James Willmore

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.


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
 
K

Keith Keller

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

....and it may be that the sysadmin is not permitted to do so. :)

Of course, none of us know the context in which the OP works. Perhaps
he can justify to his superiors that he requires DBI for his work, and
then the sysadmin can install it. These are all political, not Perl,
questions, however.

- --keith

- --
(e-mail address 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/8KquhVcNCxZ5ID8RAtE8AJ97DZ9RiCVJ+F6XdgwAc7+PbupHEwCdGthk
FvMv539QG5sP2cjUD5mDH54=
=r8bD
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top