Oracle Package:
Package Spec:
CREATE OR REPLACE PACKAGE pkg_cmt_procs
IS
TYPE refcur IS REF CURSOR;
PROCEDURE getallactiveorgs (po_refcur OUT refcur);
END pkg_cmt_procs;
/
Package Body:
CREATE OR REPLACE PACKAGE BODY pkg_cmt_procs
IS
PROCEDURE getallactiveorgs (po_refcur OUT refcur)
IS
BEGIN
OPEN po_refcur FOR
SELECT *
FROM org
WHERE orgid >= 0 AND active = 'Y'
ORDER BY orgname;
END getallactiveorgs;
PHP CODE:
$stmt2 = OCIParse($link, "begin PKG_CMT_PROCS.getallactiveorgs(:po_refcur); end;");
OCIBindByName($stmt2, ':po_refcur', $orgname);
OCIBindByName($stmt2, ':po_refcur', $orgid);
populateV4Dropdown($link, stmt2, "OrgName", "OrgID")
PopulateV4Dropdown an an other INC file.
<?PHP
function PopulateV4Dropdown ($myLink, $myQuery, $field, $value="", $selectVal="")
{
//=============================================
// Function to populate Dropdowns with DB values
//------------------------------------------------
// $myLink database link
// $myQuery query to get data
// $field Name of field whose contents we want to display
// $value Name of field whose value is to be used instead of the displayed value
// $selectVal The current selected value of the field
//------------------------------------------------
$myResult = ociexecute($myLink, $myQuery) or die();
while ($result=ocifetch($myResult))
{
$label = ociresult($myResult, $field); //get the field content
if ($value=="")
{ //not interested in values, so ...
if ($label == $selectVal)
{ //if this is also the Selected value, add the "selected" attribute
print ("<option selected value =\"".trim($label)."\">".trim($label)."</option>");
}
else
{ //otherwise just output the thing !
print ("<option value =\"".trim($label)."\">".trim($label)."</option>");
}
}
else
{ //second bite at the apple ???
$val = ociresult($myResult, $value);
if ($val == $selectVal)
{
print ("<option selected value =\"".trim($val)."\">".trim($label)."</option>");
}
else
{
print ("<option value =\"".trim($val)."\">".trim($label)."</option>");
}
}
}
};
?>
But somehow Iam not able to execute the procedure, Please help me in figuring out, How to execute a Proc in PHP?
Thanks