$dbh->prepare is hanging



Hi All,

I am trying to execute a very simple SELECT statement through Perl DBI
and it is hanging. I have actually issues this very same command at the
SQL prompt and the output is immediately returned. I turned on the
debug mode and the program hangs at:

DBD::ODBC::st::_prepare($sth, $statement, @attribs) or return undef;

The SELECT statement is as follows:

select ptnt_gid, prdct_gid, rx_fill_dte, claim_gid, ovrd_days_sply_nbr,
clfsn_grace_prd_nbr, 'N', (rx_fill_dte + ovrd_days_sply_nbr) from
p_dlvrb_rx_claim_extract where ptnt_gid = 337 and prdct_gid = 18607
order by ptnt_gid, prdct_gid, rx_fill_dte, claim_gid

main::(./step1.pl:73): $sth2 = $dbh->prepare($sqlString) || die
"$!\n";
DB<2> s
DBD::ODBC::db::prepare(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris
/DBD/ODBC.pm:90):
90: my($dbh, $statement, @attribs)= @_;
DB<2> s
DBD::ODBC::db::prepare(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris
/DBD/ODBC.pm:93):
93: my $sth = DBI::_new_sth($dbh, {
94: 'Statement' => $statement,
DB<2> s
DBI::_new_sth(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.pm:1
247):
1247: my ($dbh, $attr, $imp_data) = @_;
DB<2> s
DBI::_new_sth(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.pm:1
248):
1248: my $imp_class = $dbh->{ImplementorClass}
1249: or Carp::croak("DBI _new_sth: $dbh has no
ImplementorClass");
DB<2> s
DBI::_new_sth(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.pm:1
250):
1250: substr($imp_class,-4,4) = '::st';
DB<2> s
DBI::_new_sth(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.pm:1
251):
1251: my $app_class = ref $dbh;
DB<2> s
DBI::_new_sth(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.pm:1
252):
1252: substr($app_class,-4,4) = '::st';
DB<2> s
DBI::_new_sth(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.pm:1
253):
1253: _new_handle($app_class, $dbh, $attr, $imp_data, $imp_class);
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1161):
1161: my ($class, $parent, $attr, $imp_data, $imp_class) = @_;
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1163):
1163: Carp::croak('Usage: DBI::_new_handle'
1164: .'($class_name, parent_handle, \%attr,
$imp_data)'."\n"
1165: .'got: ('.join(", ",$class, $parent, $attr,
$imp_data).")\n")
1166: unless (@_ == 5 and (!$parent or ref $parent)
1167: and ref $attr eq 'HASH'
1168: and $imp_class);
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1170):
1170: $attr->{ImplementorClass} = $imp_class
1171: or Carp::croak("_new_handle($class): 'ImplementorClass'
attribute not given");
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1173):
1173: DBI->trace_msg(" New $class (for $imp_class,
parent=$parent, id=".($imp_data||'').")\n")
1174: if $DBI::dbi_debug >= 3;
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1177):
1177: my (%hash, $i, $h);
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1178):
1178: $i = tie %hash, $class, $attr; # ref to inner hash (for
driver)
DB<2> s
DBI::st::TIEHASH(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1188):
1188: sub DBI::st::TIEHASH { bless $_[1] => $_[0] };
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1179):
1179: $h = bless \%hash, $class; # ref to outer hash (for
application)
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1182):
1182: DBI::_setup_handle($h, $imp_class, $parent, $imp_data);
DB<2> s
DBI::_new_handle(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris/DBI.p
m:1184):
1184: return $h unless wantarray;
DB<2> s
DBD::ODBC::db::prepare(/usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris
/DBD/ODBC.pm:101):
101: DBD::ODBC::st::_prepare($sth, $statement, @attribs)
102: or return undef;
DB<2> s

Then when I break out, I get the following error:

DBD::ODBC::db prepare failed: [unixODBC]Unexpected protocol character
(SQL-08S02)(DBD: st_prepare/SQLPrepare err=-1) at

Hope someone can shed some light.

Thanks.

Peter


Relevant Pages

  • Field terminated by
    ... I have a problem using special characters in the Perl DBI. ... SQL code works without problem with mysql: ... When I try to execute it from perl as follows, ... I guess this problem is related to the field terminated by ";" part of the command. ...
    (perl.dbi.users)
  • select.select() on windows
    ... I am currently using subprocess to execute a command. ... this is hanging on a read..waiting for more ... Except I don't have a socket, i have stdout. ...
    (comp.lang.python)
  • [Full-Disclosure] Advanced usage of system() function.
    ... and call its arguments as a command for shell. ... as we can see we still didnt get what we want (typing exit ... Connection closed by foreign host. ... think what we want to execute. ...
    (Full-Disclosure)
  • Advanced usage of system() function.
    ... and call its arguments as a command for shell. ... as we can see we still didnt get what we want (typing exit we are ... Connection closed by foreign host. ... think what we want to execute. ...
    (Bugtraq)
  • Re: Wait for background processes to complete
    ... To be able to execute commands in the background and wait for their ... The documentation I am referring to is http://perldoc.perl.org/. ... You can run a command in the background with: ... There is a general problem with perl documentation: ...
    (comp.lang.perl.misc)