Hi,

I am using Perl with DBD-ODBC to extract live values from an Wonderware
Industrial SQL which runs on top of a Microsoft SQL Server.

The platform is Windows NT 4.0, Microsoft SQL Server 6.50.193 and Industrial
SQL version 7.0.211, Microsoft SQL Server ODBC version 3.70.0961.

When I use:
  DBI prepare  - SQLPrepare
  DBI execute  - SQLExecute
  DBI fetchrow - SQLFetch
to select the live data from the Industrial SQL it returns no rows.
This is due to the fact that only the SQLExecDirect ODBC function will cause
Industrial SQL to access and provide the live data.

When using Microsoft MDAC ODBC Test the data are provided with no problems.

In other words I need to make DBI use the ExecDirect ODBC function.

Can I do this in a way that will allow me to use the DBI fetchrow to read
the data?

I have read in a release note for DBD-ODBC 0.35 that $dbh->func( $stmt,
ExecDirect) can be used to call ExecDirect, but will this allow me to read
the data afterwards?

I have tried to use the following code without success:

  use DBI;

  my ($dbname, $user, $pass, $dbh, $sth, @row);

  $dbname = "INSQL";
  $user = "wwUser";
  $pass = "wwUser";
  $dbh = DBI->connect("dbi:ODBC:$dbname", $user, $pass)
    || die "Unable to connect to $dbname: $DBI::errstr\n";

  my $stmt = qq( select TagName, DateTime, Value from "AnalogLive" where
TagName in $tags );
  $sth = $dbh->func( $stmt, ExecDirect);
  if ($sth) {
    while (@row = $sth->fetchrow_array( ) ) {
      $tag = $row[0];
      $time = $row[1];
      $value = $row[2];
      printf "[%s] %s %s\n", $tag, $value, $time;
    }
  } else {
    printf "No statement handle\n";
  }
  $dbh->disconnect( );


I get the following error message:
  Can't call method "fetchrow_array" without a package or object reference
at C:\Work\Scripts\insqltest.pl line 15.

Do anyone have examples of how to use ExecDirect in connection with fetch?

Are there any hope of making this work through DBD-ODBC or should I rather
attempt to use Win32::ODBC?



Best Regards

Michael Riber
Project Manager
________________________________________________
ROVSING Dynamics A/S
Dyreg�rdsvej 2
DK-2740  Skovlunde
Denmark

Phone:          +45 44 200 800
Direct:         +45 44 200 826
Mobile:         +45 20 19 26 16
Fax:            +45 44 200 801
e-mail:         [EMAIL PROTECTED]
Web:            www.rovsing-dynamics.com
������������������������������������������������



Reply via email to