while loop problem with oracle binding

wxdqz

New Member
Hey guys, i'm stuck on something. Here's the problem in very rough form:

$conn = OCILogon("blah","blah","blah");

$sql = "SELECT LONG_QUERY, SHORT_QUERY FROM SOME_TABLE WHERE STUFF = 'SOMETHING';

$stmt = OCIParse($conn,$sql);

OCIDefineByName($stmt,"LONG_QUERY",&$longquery);
OCIDefineByName($stmt,"SHORT_QUERY",&$shortquery);

OCIExecute($stmt);

while(OCIFetch($stmt)){
if($longquery){ //here is the problem
echo $longquery;
echo $shortquery;
} else {
echo "no longquery";
break;
}
}

OCIFreeStatement($stmt);
OCILogoff($conn);

Now the problem is, even if $longquery is empty, the while loop goes on and does not jumpt to "no longquery". In other words, no error is generated. I've tried everything that I can think of to trap that value, but for some reason, the script evaluates $longquery as true, and therefor the while loop executes.

Does anyone have any idea of how I can make this work the way I intend it? I'm problably just being blind after many hours of coding, but any help would be appriciated. Thanks.
 
Back
Top