Oracle and stored procedures
| From: | Paulson, Joseph V. \"Jay\" | Date: | Tue, 12 Sep 2000 20:19:51 +0000 |
| Subject: | Oracle and stored procedures | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-16437@lists.php.net to get a copy of this message | ||
Hello everyone--
I'm working on getting oracle stored procedures to work in php. I've
noticed a lot of people doing this same thing. I have also been searching
the archives to try and solve my problems in just understanding what needs
to be done. Below is the stored procedure and the values that need to be
passed to it. My question is how exactly do you do this? Here's what I
know so far and of course it doesn't work when i test it :)
$conn = OCILogon("username","password","dbname");
$curs = OCINewCursor($conn);
/****************************************************
* Here is the stored procedure:
* What it is going to do is add data to the database
* and return to two OUT vars. What I need is to
* somehow enter the data and be able to get the two
* returned vars out of this so I can run a check to
* see if it worked.
*
* Procedure NAC_CONTACT_ADD
* (
* P_RETURN_CODE OUT NUMBER,
* P_RETURN_MSG OUT VARCHAR2,
* p_acct_no IN CONTACT.ACCT_NO %TYPE,
* p_div IN CONTACT.DIV %TYPE,
* p_cde_action IN VARCHAR2,
* p_name IN CONTACT.NAME %TYPE,
* p_phone_no IN CONTACT.PHONE_NO %TYPE,
* p_phone_type IN CONTACT.PHONE_TYPE %TYPE,
* P_LOGIN_ID IN CONTACT.LAST_CHANGED_BY %TYPE,
* P_CONTACT_ID IN CONTACT.CONTACT_ID %TYPE,
* P_COMMIT IN CHAR
* )
****************************************************/
/****************************************************
* Here are the values that need to be passed to it:
*
* Pass in these values:
*
* p_acct_no = 1160000001
* p_div = 116
* p_CDE_ACTION = Order
* p_name = Php Test
* p_PHONE_NO = 6914417
* p_PHONE_TYPE = PHONE
* p_login_id = WEB
* p_contact_id =
* p_commit = Y
****************************************************/
$stmt = OCIParse($conn,"begin :return_value := NAC_CONTACT_ADD(:p_acct_no,
:p_div, :p_CDE_ACTION,
:p_name, :p_PHONE_NO, :p_PHONE_TYPE, :p_login_id,
:p_contact_id, :p_commit); end;");
//is this correct??
ocibindbyname($stmt,"return_value",&$retval,-1);
ocibindbyname($stmt,"p_acct_no",&$p_acct_no,-1);
ocibindbyname($stmt,"p_div",&$p_acct_no,-1);
ocibindbyname($stmt,"p_CDE_ACTION",&$p_CDE_ACTION,-1);
ocibindbyname($stmt,"p_name",&$p_name,-1);
ocibindbyname($stmt,"p_PHONE_NO",&$p_PHONE_NO,-1);
ocibindbyname($stmt,"p_PHONE_TYPE",&$p_PHONE_TYPE,-1);
ocibindbyname($stmt,"p_login_id",&$p_login_id,-1);
ocibindbyname($stmt,"p_contact_id",&$p_contact_id,-1);
ocibindbyname($stmt,"p_commit",&$p_commit,-1);
OCIExecute($stmt);
OCIFreeStatement($stmt);
OCILogoff($conn);