OCI8 help?
| From: | php at home dot uh dot nu | Date: | Tue, 14 Mar 2000 03:43:16 +0000 |
| Subject: | OCI8 help? | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12079@lists.php.net to get a copy of this message | ||
Howdy,
I'm having a problem making a call to a stored procedure using php4.
I'm getting an error from plsql
Warning: OCIStmtExecute: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments
in call to
'DO_PURCHASE' ORA-06550: line 1, column 7: PL/SQL: Statement ignored in
/usr/www/site/htdocs/rc/php/rcClass_Rocketpay.php on line 189
I have checked the number of arguments and they are correct. The only thing I can think of,
is that calling a stored procedure with some parameters as a php array doesn't work.
In PRO C I can call an oracle stored procedure with one of the parameters being an
array of strings or array of ints, depending on the parameter in question. So how can I call this
stored procedure correctly in php? Here is the code in question.
The stored proc is defined as
SQL> desc do_purchase;
PROCEDURE do_purchase
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
I_MERCHANT_ID NUMBER(20) IN
I_LOGON_NAME VARCHAR2(20) IN
I_PASSWORD VARCHAR2(20) IN
I_NUMBER_OF_ITEMS NUMBER IN
I_SKU TABLE OF VARCHAR2(20) IN
I_DESCRIPTION TABLE OF VARCHAR2(100) IN
I_QUANTITY TABLE OF NUMBER IN
I_COST TABLE OF NUMBER IN
I_PURCHASE_ITEM_AMOUNT NUMBER IN
I_PURCHASE_SHIPPING NUMBER IN
I_PURCHASE_TAX NUMBER IN
I_DISCOUNT NUMBER IN
I_PURCHASE_TOTAL NUMBER IN
O_TRANSACTION_ID NUMBER(20) OUT
O_FINAL_BALANCE NUMBER OUT
O_FIRST_NAME VARCHAR2(100) OUT
O_MIDDLE_INITIAL VARCHAR2(10) OUT
O_LAST_NAME VARCHAR2(50) OUT
O_STREET1 VARCHAR2(100) OUT
O_STREET2 VARCHAR2(100) OUT
O_CITY VARCHAR2(100) OUT
O_STATE VARCHAR2(2) OUT
O_ZIPCODE VARCHAR2(10) OUT
O_DAY_PHONE VARCHAR2(20) OUT
O_EMAIL VARCHAR2(50) OUT
O_RESULT_CODE NUMBER OUT
The parameters in question are I_SKU, I_DESCRIPTION, I_QUANTITY, and I_COST.
Here is my class function that calls the stored proc.
$item_skus, $item_descriptions, $imte_quantity and $item_cost are php arrays.
function do_purchase($connection, $merchant_id, $logon_name, $password, $num_items, $item_skus,
$item_descriptions,
$item_quantity, $item_cost, $purchase_amount, $purchase_tax,
$purchase_discount, $purchase_total)
{
$res = -1;
$query = "BEGIN do_purchase($merchant_id, :logon_name, :password, :num_items, :item_skus,
:item_desc, ";
$query .= ":item_quantity, :item_cost, :purchase_amount, :purchase_shipping,
:purchase_tax, :purchase_discount, :purchase_total, ";
$query .= ":transaction_id, :final_balance, :first_name, :middle_initial, :last_name,
:address1, :address2, ";
$query .= ":city, :state, :zipcode, :telephone, :email, ";
$query .= ":res);";
$query .= "END;";
//echo "query= $query<br>";
//exit();
$stmt = OCIParse($connection->connection, $query);
OCIError();
OCIBindByName($stmt, ":logon_name", &$logon_name, 21);
OCIBindByName($stmt, ":password", &$password, 21);
OCIBindByName($stmt, ":num_items", &$num_items, 10);
OCIBindByName($stmt, ":item_skus", &$item_skus, 32);
OCIBindByName($stmt, ":item_desc", &$item_desc, 32);
OCIBindByName($stmt, ":item_quantity", &$item_quantity, 32);
OCIBindByName($stmt, ":item_cost", &$item_cost, 32);
OCIBindByName($stmt, ":purchase_amount", &$purchase_amount, 32);
OCIBindByName($stmt, ":purchase_shipping", &$purchase_shipping, 32);
OCIBindByName($stmt, ":purchase_tax", &$purchase_tax, 32);
OCIBindByName($stmt, ":purchase_discount", &$purchase_discount, 32);
OCIBindByName($stmt, ":purchase_total", &$purchase_total, 32);
OCIBindByName($stmt, ":transaction_id", &$this->transaction_id, 32);
OCIBindByName($stmt, ":final_balance", &$this->final_balance, 32);
OCIBindByName($stmt, ":first_name", &$this->first_name, 51);
OCIBindByName($stmt, ":middle_initial", &$this->middle_initial, 11);
OCIBindByName($stmt, ":last_name", &$this->last_name, 51);
OCIBindByName($stmt, ":address1", &$this->address1, 101);
OCIBindByName($stmt, ":address2", &$this->address2, 101);
OCIBindByName($stmt, ":city", &$this->city, 101);
OCIBindByName($stmt, ":state", &$this->state, 3);
OCIBindByName($stmt, ":zipcode", &$this->zipcode, 11);
OCIBindByName($stmt, ":telephone", &$this->telephone, 21);
OCIBindByName($stmt, ":email", &$this->email, 51);
OCIBindByName($stmt, ":res", &$res, 32);
OCIExecute($stmt);
OCIFreeStatement($stmt);
return $res;
}
Thanks for the help
Walt