How to call package from php having procedure in oracle using oci drivers?

假如想象 提交于 2019-12-23 01:28:23

问题


I am calling oracle package having procedure using oci drivers. I am getting error as

Warning: oci_execute() [function.oci-execute]: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'GET_BRAND_MODEL_LIST' ORA-06550: line 1, column 7: PL/SQL: Statement ignored in /opt/lampp/htdocs/call.php on line 26

All parameters are correct. $p_contract_no = '11-col1-cm';
$p_utilityagencyname='ATM';
$p_appliance_type='BO';
$p_tier_type=1;
$p_brand_code =NULL;
$p_execution_type='brand';

$query="begin process_101.get_brand_model_list(:p_contract_no, :p_utilityagencyname, :p_appliance_type, :p_tier_type, :p_brand_code, :p_execution_type, :r); end;";

$stid = oci_parse($conn, $query);
oci_bind_by_name($stid, ":p_contract_no", & $p_contract_no);
oci_bind_by_name($stid, ":p_utilityagencyname", & $p_utilityagencyname);
oci_bind_by_name($stid, ":p_appliance_type", & $p_appliance_type);
oci_bind_by_name($stid, ":p_tier_type", & $p_tier_type);
oci_bind_by_name($stid, ":p_brand_code", & $p_brand_code);
oci_bind_by_name($stid, ":p_execution_type", & $p_execution_type);
oci_bind_by_name($stid, ":r", $r);
oci_execute($stid);
please help if anyone have solution to my problem. Thanks in advance..


回答1:


As far as I remember you have to specify type and maxlength to oci_bind_by_name() for variables returned from the procedure.

Assuming :r is the OUT variable, try:

oci_bind_by_name($stid, ":r", $r, 50, SQLT_CHR);

The following code works for returning a value from an Oracle procedure (Zend_Db_Adapter_Oracle version):

$statement = $db->prepare('BEGIN oracle_procedure(:result); END;');
$statement->bindParam('result', $result, SQLT_CHR, 12);
$statement->execute();
echo $result;


来源:https://stackoverflow.com/questions/5750797/how-to-call-package-from-php-having-procedure-in-oracle-using-oci-drivers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!