Hello I am having a real issue with a select statement. The query works just fine in toad but i cannot get it to work through php. Here is what I have: //getting info for items that match search screen $sql = "select a.tdm_id, a.revision, a.file_name, a.file_type, a.object_id, a.class_id "; $sql .= "from tn_documentation a "; $sql .= "where tdm_id like '$PartNumber' "; $sql .= "and state=3 "; $sql .= "and class_id <> 1023 "; $sql .= "and class_id <> 709 "; if (isset($_GET['chkLatestRev'])) { $sql .= "and creation_date=(select max(creation_date) from tn_documentation where tdm_id=a.tdm_id) "; } $sql .= "order by tdm_id asc"; $stid = oci_parse($c, $sql); oci_execute($stid, OCI_DEFAULT); if (!oci_fetch_object($stid)) { $ERROR++; } else { while ($myrow = oci_fetch_array ($stid, OCI_NUM)) { blah blah } if I take out all but one of the and conditions it works fine. Im stumped... Has anyone ran across this before..?? thanks Mike
OK..I figured it out...it was actually the error checking not the query... problem code: oci_execute($stid, OCI_DEFAULT); if (!oci_fetch_object($stid)) { $ERROR++; } else {
Another easy way to figure out the sql query problems.echo the query,copy it and execute in the db it will explain the exact problem.