You missed the fetch step. there are 3 steps to this. prepare the sql
statement, execute the statement, and then fetch the data in a while or
for-next loop where you do something  with the data you retrieve.


Miguel


Judge Dredd wrote:

> Hello there!
>
> I have a database in access and I'm trying (with perl using DBI and
> DBD::ODBC in win32) to select specific fields from it and write them to a
> file. The script that I'm using is the one I'm providing below. The
> connection to the database works fine but I think there is a problem with
> the SELECT statement. The only thing that gets printed in the file is
> DBI::st=HASH(0x1914394) which is the only thing that I get as a response
> when the script runs. Essentially the problem is that I can not print the
> results of the query. Do you have any ideas on this? Any help would be
> much appreciated.
>
> For those in multiple lists sorry for the cross-post
>
> Thanks in advance.
>
> #!perl
>
> use DBI;
> use strict;
>
> my $DSN = 'driver=Microsoft Access Driver (*.mdb);
> dbq=\\\\server\\path\\to\\database\\db1.mdb';
> my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n";
> $dbh->{AutoCommit} = 1;$dbh->{RaiseError} = 1;
>
>         my $sth = $dbh->prepare(q{
>         SELECT (DNS_id, help) FROM DNS}) || die $dbh->errstr;
>         chop;
>         $sth->execute() || die $dbh->errstr;
>
> unless (open(ZONEFILE2, ">zonefile2")){
>         die ("Missing File");
> }
>
> print ZONEFILE2 "$sth";
> close(ZONEFILE2);
>
> $sth->finish;
> $dbh->disconnect;
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> _______________________________________________
> Perl-Win32-Database mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-database

--
Want a REALLY MAD COW?
                                        /;    ;\
                                   __  \\____//
                  MOOO DARNIT!    /{_\_/  \`'\_/__
                                  \___   (o\  /o  }
       _____________________________/          :--'
   ,-,'`@@@@@@@@       @@@@@@         \_    `__\
  ;:(  @@@@@@@@@        @@@             \___(o'o)
  :: )  @@@@          @@@@@@        ,'@@(  `===='
  :: : @@@@@:          @@@@         `@@@:
  :: \  @@@@@:       @@@@@@@)    (  '@@@'
  ;; /\      /`,    @@@@@@@@@\   :@@@@@)
  ::/  )    {_----------------:  :~`,~~;
 ;;'`; :   )                  :  / `; ;
;;;; : :   ;                  :  ;  ; :
`'`' / :  :                   :  :  : :
    )_ \__;                   :_ ;  \_\
    :__\  \                   \  \  :  \
        `^'                    `^'  `-^-'

Reply via email to