I have asite that connects to an Oracle DB. One of the functions that I have put together and tested runs great when I execute it in SQLPlus but I get the following error in php
Warning: OCIStmtExecute: ORA-00900: invalid SQL statement
it is telling me that my line 26:
$exec = OCIExecute($sql_st); is where it is failing. The remainder of the code looks like this. Variables have been assigned for testing purposes.:
$mfg_id = 113;
$search_like = "'%lmc1-00410%'";
$search_1 = "'lmc1-00410'";
$sql = "$sql = select distinct p.product_id,p.name from product p, mfg_relations mr
where (lower(p.name) like lower($search_like)
or lower(p.upc_code) = lower($search_1)
or lower(p.mfg_part_number) = lower($search_1)
or lower(p.product_id) = lower($search_1)
or lower(p.category) like lower($search_like)
or lower(p.subcategory) like lower($search_like))
and (((p.mfg_id = mr.mfg_id1
and p.deleted = 'N'
and mr.mfg_id = $mfg_id
and mr.restriction = 'only')
and
((mr.affected_level = 'category' or p.category = mr.affected_unit)
or(mr.affected_level = 'all')
or(mr.affected_level = 'subcategory' and p.subcategory = mr.affected_unit)
or(mr.affected_level = 'item' and p.product_id = mr.affected_unit)))
or p.mfg_id = $mfg_id)";
$sql_st = OCIParse($conn,$sql);
var_dump($sql_st);
$exec = OCIExecute($sql_st);
while (OCIFetchInto($sql_st, $row, OCI_ASSOC))
{
$product_id = $row[PRODUCT_ID];
$name = $row[NAME];
echo "<TR><TD>".$product_id."</td><TD>".$name."</td></tr>";
}
OCIFreeStatement($sql_st);
Warning: OCIStmtExecute: ORA-00900: invalid SQL statement
it is telling me that my line 26:
$exec = OCIExecute($sql_st); is where it is failing. The remainder of the code looks like this. Variables have been assigned for testing purposes.:
$mfg_id = 113;
$search_like = "'%lmc1-00410%'";
$search_1 = "'lmc1-00410'";
$sql = "$sql = select distinct p.product_id,p.name from product p, mfg_relations mr
where (lower(p.name) like lower($search_like)
or lower(p.upc_code) = lower($search_1)
or lower(p.mfg_part_number) = lower($search_1)
or lower(p.product_id) = lower($search_1)
or lower(p.category) like lower($search_like)
or lower(p.subcategory) like lower($search_like))
and (((p.mfg_id = mr.mfg_id1
and p.deleted = 'N'
and mr.mfg_id = $mfg_id
and mr.restriction = 'only')
and
((mr.affected_level = 'category' or p.category = mr.affected_unit)
or(mr.affected_level = 'all')
or(mr.affected_level = 'subcategory' and p.subcategory = mr.affected_unit)
or(mr.affected_level = 'item' and p.product_id = mr.affected_unit)))
or p.mfg_id = $mfg_id)";
$sql_st = OCIParse($conn,$sql);
var_dump($sql_st);
$exec = OCIExecute($sql_st);
while (OCIFetchInto($sql_st, $row, OCI_ASSOC))
{
$product_id = $row[PRODUCT_ID];
$name = $row[NAME];
echo "<TR><TD>".$product_id."</td><TD>".$name."</td></tr>";
}
OCIFreeStatement($sql_st);