oracle 如何使用oci驱动程序从具有oracle程序的php调用包?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5750797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to call package from php having procedure in oracle using oci drivers?
提问by Manoj
I am calling oracle package having procedure using oci drivers. I am getting error as
我正在调用具有使用 oci 驱动程序的程序的 oracle 包。我收到错误
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
警告:oci_execute() [function.oci-execute]:ORA-06550:第 1 行,第 7 列:PLS-00306:调用“GET_BRAND_MODEL_LIST”时参数的数量或类型错误 ORA-06550:第 1 行,第 7 列:PL /SQL:第 26 行 /opt/lampp/htdocs/call.php 中的语句被忽略
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..
所有参数都正确。
$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);
如果有人解决了我的问题,请帮忙。提前致谢..
回答by vls
As far as I remember you have to specify type
and maxlength
to oci_bind_by_name()
for variables returned from the procedure.
至于我记得你必须指定type
,并maxlength
以oci_bind_by_name()
从过程返回变量。
Assuming :r
is the OUT
variable, try:
假设:r
是OUT
变量,请尝试:
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_Oracleversion):
以下代码适用于从 Oracle 过程(Zend_Db_Adapter_Oracle版本)返回值:
$statement = $db->prepare('BEGIN oracle_procedure(:result); END;');
$statement->bindParam('result', $result, SQLT_CHR, 12);
$statement->execute();
echo $result;