you can if you prepare and use fetchrow_hashref and rows...


use DBI;
use ORA;

my $dbh = DBI->connect(...connect stuff here...)) || die $DBI::errstr;
my $sql = "select * from sfile";
my $sth = $dbh->prepare($sql) || die $dbh->errstr;
$sth->execute || die $sth->errstr;
while (my $href = $sth->fetchrow_hashref) {
    .... do something with row here
}
die $sth->errstr if $sth->errstr;
my $rows = $sth->rows;
print "rows = $rows\n";


"Rozengurtel, Daniel" wrote:

> Hello,
> I am executing a query that in some cases dont have an entry for the
> instrument_id I am using to retrieve by. I.e there is no physically record
> in there (NVL wouldnt work).
> This is a peice of code i am struggking with:
> undef $ticker;
>         $sql="SELECT SUBSTR(ISS_ID,1, INSTR(ISS_ID,' ',1) -1), INST_MNEM
>                       FROM FT_T_ISID WHERE INSTR_ID='$instr_id'
>                  AND ID_CTXT_TYP='TICKER' AND SUBSTR(ISS_ID,INSTR(ISS_ID,'
> ',1) +1,99)='US'
>                  AND last_chg_usr_id <>'ADP'";
>
>   $sth = $dbh->prepare($sql) or die "Can't execute query $DBI::errstr";
>         $sth->execute;
>
>     my $ticker_ref = $dbh->selectall_hashref($sql);
>                 foreach  my $tick (@$ticker_ref){
>                         $ticker=(defined
> $tick->{ISS_ID})?$tick->{ISS_ID}:"NONE";
>                            last;
>                     }
>
> In the case TICKER is not found in the DB for a particular ID the code
> doesnt assign value NONE to a $ticker.
> My question:
> Is there anything  like , maybe $rc that after each transaction/sql call I
> will be able to see whether the query returned results (true/false)? Maybe I
> can base my assignment of NONE on that factor?
> Thanx
> Daniel Rozengurtel
> Analyst II -Data Mining/WHSE
> IT Clearing-Settlements
> Banc of America Securities, LLC
> 9 West 57th Street, 18th Floor, NYC
> Email: [EMAIL PROTECTED]
> Phone: (212) 847-6253
>
>
> _____________________________________________________________________
> IMPORTANT NOTICES:
>           This message is intended only for the addressee. Please notify the
> sender by e-mail if you are not the intended recipient. If you are not the
> intended recipient, you may not copy, disclose, or distribute this message
> or its contents to any other person and any such actions may be unlawful.
>
>          Banc of America Securities LLC("BAS") does not accept time
> sensitive, action-oriented messages or transaction orders, including orders
> to purchase or sell securities, via e-mail.
>
>          BAS reserves the right to monitor and review the content of all
> messages sent to or from this e-mail address. Messages sent to or from this
> e-mail address may be stored on the BAS e-mail system.

Reply via email to