I have a Oracle stored procedure that has an IN OUT cursor parameter.
SP_GET_RATES
(
M_CHECKIN_DATE VARCHAR2,
M_CHECKOUT_DATE VARCHAR2,
M_CURRENCY VARCHAR2,
M_RESULT IN OUT SASIAPLSQLTAB.SEARCH_RESULT_CURSOR
)
In Yii2 im trying to use this method to get the procedure result.
$params = array(
':1' => '20-Nov-2015',
':2' => '21-Nov-2015',
':3' => 'USD'
);
$stmt = $connection->createCommand("CALL SP_GET_RATES(:1,:2,:3,:4)", $params);
$stmt->bindParam(':4', $return_cursor,\PDO::PARAM_STR|\PDO::PARAM_INPUT_OUTPUT,4000);
$stmt->queryAll();
But when executing this I'm getting error.
SQLSTATE[HY000]: General error: 6553 OCIStmtExecute: ORA-06553: PLS-306: wrong number or types of arguments in call to 'SP_GET_RATES'
(ext\pdo_oci\oci_statement.c:148)
The SQL being executed was: CALL SP_GET_RATES('20-Nov-2015','21-Nov-2015','USD',NULL)
I tried differnt ways to bind the values but still I can't figure out how to bind IN OUT cursor parameter in Yii2. And I think Yii2 using PDO OCI to connect oracle database.
Yii 2.0.6 PHP 5.5.24 Oracle 11g
Seem you are calling a SP with four argument
CALL SP_GET_RATES(:1,:2,:3,:4)
but you pass only three or you use the wrong type for the value
$params = array(
':1' => '20-Nov-2015',
':2' => '21-Nov-2015',
':3' => 'USD'
);
PDO::oci does not support REF CURSORS. Reference: http://php.net/manual/en/ref.pdo-oci.php
But for Yii there is a workaround by using oci8 which supports cursors and is well supported by Yii.
Yii has oci8 extensions. Which makes using oci8 easier and its better in terms of perfomrnce compared to pdo_oci. Reference: http://www.yiiframework.com/extension/oci8pdo
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.