kamesh3183 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have select query as following: Select domain_id from networks_full where netnumber = hextoraw('3E198000').
I need to implement similar query through perl DBI..So I have written it as
use strict; use DBI; my $domain_id; my $dbh = DBI->connect("dbi:Oracle:host=$dbhost;sid=$dbname;port=15 +21", "$dbuser/$dbpass", "") or die "unable to connect: $DBI::errstr\n +"; my $statement = qq|select domain_id from networks_full where netnumbe +r = hextoraw(?)|; #netnumber is raw type. my $sth = $dbh->prepare($statement) or die "Couldn't prepare statement +: $DBI::errstr; stopped"; my $hexnetnumber = '3E198000'; $sth->execute($hexnetnumber) or die "Couldn't execute statement: $DBI: +:errstr; stopped"; while(my $ref = $sth->fetchrow_hashref()) { $domain_id = $ref->{'domain_id'}; } $sth->finish; print "domain_id is:",$domain_id,"\n"; $dbh->disconnect;
when I execute this script its not returning any data while i query the database through SQL*Plus it is returning data. So i think there must be some problem while converting hex to raw. please help me..

Replies are listed 'Best First'.
Re: Problem with oracle hextoraw function
by virtualsue (Vicar) on Apr 23, 2005 at 12:59 UTC
    Have you tried turning on DBI's tracing capabilities? DBI provides several different trace levels. You can control tracing with DBI->trace( 1-4[, "logfilename"] );. You can also trace per handle, but you won't need to do that here. By default, the trace output will go to dbitrace.log. You can also set the logfile name and trace level via the environment variable $DBI_TRACE.

    DBI_TRACE value     Effect
    1                   DBI->trace(1);  # legal values: 0-4
    mytracefile.name    DBI->trace(2, 'mytracefile.name');
    3=logfile.txt       DBI->trace(3, 'logfile.txt');
    
    Trace Levels        Effect
    0                   Off
    1                   Trace method execution inc returned values and errors
    2                   1 + method entry & parameters
    3                   2 + more internal trace info
    4                   3 + the kitchen sink