isql in perl

Discussion in 'Perl Misc' started by mike, Dec 26, 2003.

  1. mike

    mike Guest

    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...
    mike, Dec 26, 2003
    #1
    1. Advertising

  2. 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
    Gregory Toomey, Dec 26, 2003
    #2
    1. Advertising

  3. mike

    mike Guest

    Gregory Toomey <> 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
    mike, Dec 27, 2003
    #3
  4. mike <> 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
    Nicholas Dronen, Dec 27, 2003
    #4
  5. On 26 Dec 2003 18:35:50 -0800
    (mike) wrote:
    > Gregory Toomey <> 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?
    James Willmore, Dec 29, 2003
    #5
  6. "James Willmore" <> wrote in message
    news:...
    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
    Ragnar Hafstað, Dec 29, 2003
    #6
  7. On Mon, 29 Dec 2003 16:33:57 -0000
    "Ragnar Hafstað" <> wrote:

    > "James Willmore" <> wrote in message
    > news:...
    > 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.
    James Willmore, Dec 29, 2003
    #7
  8. mike

    Keith Keller Guest

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

    On 2003-12-29, James Willmore <> 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

    - --
    -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-----
    Keith Keller, Dec 29, 2003
    #8
  9. "Keith Keller" <-francisco.ca.us> wrote in message
    news:-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
    Ragnar Hafstað, Dec 29, 2003
    #9
  10. On Mon, 29 Dec 2003 09:40:03 -0800
    Keith Keller <-francisco.ca.us> wrote:

    > On 2003-12-29, James Willmore <> 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
    James Willmore, Dec 29, 2003
    #10
  11. mike

    Keith Keller Guest

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

    On 2003-12-29, Ragnar Hafstað <> wrote:
    > "Keith Keller" <-francisco.ca.us> wrote in message
    > news:-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


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

    - --
    -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-----
    Keith Keller, Dec 29, 2003
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,791
  2. Remi Morin
    Replies:
    0
    Views:
    516
    Remi Morin
    Oct 23, 2006
  3. peterff66

    subprocess & isql

    peterff66, Jul 15, 2011, in forum: Python
    Replies:
    1
    Views:
    278
    sturlamolden
    Jul 15, 2011
  4. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Jan 23, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    297
    PerlFAQ Server
    Jan 23, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    677
    PerlFAQ Server
    Feb 3, 2011
Loading...

Share This Page