Database access

Hell all,

I have the following snippet of code:

$sql=qq{select * from (
select to_char(t.start_time_timestamp,'yyyy/mm/dd hh24:mi:ss') start_time,t.s_p_number_address, null cos_icsa_code, null cos_icsa_subcode from cc_unrated_msc_flow t
union
select to_char(r.start_time_timestamp,'yyyy/mm/dd hh24:mi:ss') start_time,r.s_p_number_address, r.cos_icsa_code, r.cos_icsa_subcode from cc_unrated_icsa_flow r
)
order by start_time, s_p_number_address};

$sth = $dbh->prepare( $sql );
$sth->execute( );

while(@row = $sth->fetchrow_array()) {
print("MATCH FOUND!\n");
open (DEST1, ">>/opt/rap/preprocessing/unrated_output/TEMP1")||die "$!";
print DEST1 (join ("|", @row), "\n");
}

How can i indicate that $sth->fetchrow_array failled to retrieve a specific line? Can i print tis line?

Thank you very much
Chris

$rowsreturned = $sth->rows;

This will tell you how many or if any rows were returned.

Is that what your looking for?

Will the below part of code provide me an error message if the $sth->fetchrow_array( ) fails for any reason? Is there any way to know the data (@row) for which the $sth->fetchrow_array( ) has failed?

Ikon what i need to know is chich row is not returned..

while ( @row = $sth->fetchrow_array( ) ) {
print "Row: @row\n";
}
warn "Data fetching terminated early by error: $DBI::errstr\n"
if $DBI::err;