Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Extracting data from an Ms ACCESS query

by blackadder (Hermit)
on Jun 11, 2004 at 11:58 UTC ( #363383=note: print w/replies, xml ) Need Help??


in reply to Re: Extracting data from an Ms ACCESS query
in thread Extracting data from an Ms ACCESS query

Thanks, I see your point but to start off with I will carry on with ODBC.

Anyway, this is what I tried;
use Win32; use Win32::ODBC; my $dsn = "Hydra_FE"; my $qry = "dbo_vfunction_application"; my $dbh = new Win32::ODBC($dsn) || die "\nError=>\t$^E : $!\n"; print "\nError: $^E\n" if (! $dbh); my $result = $dbh->selectall_arrayref("SELECT DISTINCT(application) FR +OM dbo_vfunction_application WHERE group_name='Procurement'"); foreach (@$result) { print @$_; }
and this was what I got;
Can't locate auto/Win32/ODBC/selectall_a.al in @INC (@INC contains: C: +/Perl/lib C:/Perl/site/lib .) at U:\scripts\odbc1.pl line 14
Any thoughts? Thanks

Blackadder

Replies are listed 'Best First'.
Re^3: Extracting data from an Ms ACCESS query
by Joost (Canon) on Jun 11, 2004 at 12:00 UTC
Re^3: Extracting data from an Ms ACCESS query
by blackadder (Hermit) on Jun 11, 2004 at 12:16 UTC
    Yes, I tried this;
    my $result = $dbh->sql("SELECT * FROM $qry WHERE group_name='Procureme +nt'"); foreach (@$result) { print @$_; }
    and I got this;
    Can't use string ("1") as an ARRAY ref while "strict refs" in use at U +:\scripts\odbc1.pl line 15.
    Hmmmm. Holy ones please HELP!

    Blackadder

      Hi, blackadder

      have you read the documents Win32::ODBC?

      As has already been said, it's $dbh->Sql($statement) not $dbh->sql() and it does not return an arrayref... it returns undef upon success!

      $sql="select * from foo"; if($db->Sql($sql)) { warn "i failed: " . $db->Error(); }else{ print "read the documentation on FetchRow(), Data() and DataHash() +\n"; }

      HTH - Mark

      Thanks maa

      Yes I have read the Win32::ODBC but there is no examples it it!!!

      but so far you have given me enough stuff to work on...Cheers

      Blackadder
        Use DBD::ODBC instead of Win32::ODBC. It is much better documented, supported, and widely known.
      Darn, I meant to include this in my post below. To sort of repeat myself, the Sql call in Win32::ODBC will return either false, for a successful query or an error number if the query fails. You are storing this number in $result and trying to use it as an array reference in your print statement. From your print error message, your sql call is returning the value "1" which I think is an error from the Win32::ODBC module itself. The ODBC statement is actually $dbh->Sql() not $dbh->sql().

      PJ
      We are drowning in information and starving for knowledge - Rutherford D. Rogers
      What good is knowledge if you have to pull teeth to get it - anonymous

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://363383]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2023-12-01 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?