in reply to Value to Sub

Check the result of prepare and execute. I bet you're getting a syntax error, and the fetch is giving you that error. More specifically, you're not escaping $X_Y and $check, and you're not quoting $check. I prefer replaceable parameters instead of building a SQL string dynamically where possible. If you use replaceable parameters, you don't have to quote or escape, and you're safe from SQL injection attacks.

$sql= "SELECT C.mast1, C.mast2 FROM MASTER WHERE C.mast1=? AND C.mast2 +=?"; $sth = $dbh->prepare($sql) or die(...); $sth->execute($check, $X_Y) or die(...); ...

Replies are listed 'Best First'.
Re^2: Value to Sub
by Yendor (Pilgrim) on Nov 11, 2004 at 15:20 UTC

    Another possible problem is that the OP uses the table alias C, but never defines it anywhere that I can see (no pun intended.) Perhaps what was meant was:

    $sql= "SELECT C.mast1, C.mast2 FROM MASTER AS C WHERE C.mast1=? AND C.mast2=?";