使用php使用存储过程从Oracle数据库中获取信息

时间:2019-01-22 15:21:14

标签: php oracle

请特别使用Oracle数据库编写PHP的新手……现在我正试图从数据库中获取信息,但它并没有显示任何内容。

这是我的存储过程。

    CREATE OR REPLACE procedure COWRY.CATIP_CRM__OFR_ACCT_LIST (crm_name IN VARCHAR2 ) 
IS

Account_Officer_Name VARCHAR2(50);
Customer_ID  VARCHAR2(50);
Account_ID VARCHAR2(50);
Account_Description VARCHAR2(75);
Email VARCHAR2(50);

cursor acct_list is
select cst_id  , act_id , INITCAP(act_dsc) act_dsc , pry_eml_adr, INITCAP(acct_ofr) acct_ofr
-- INTO
-- Customer_ID , Account_ID  , Account_Description  ,Email  , Account_Officer_Name
from
(
select cst_id  , act_id , act_dsc , pry_eml_adr ,
(SELECT ofr_nme FROM CS_VL_00_CUS WHERE CUS_ID = T.Cst_ID) acct_ofr
 from CS_V_01_DD_ACT t
 )
where upper(acct_ofr) = UPPER(crm_name);

BEGIN

   dbms_output.put_line('Customer ID' ||'|'|| 'Account ID'  ||'|'|| 'Account Description'  ||'|'||'E-mail'  ||'|'|| 'Account Officer Name');

   open acct_list;
            loop
            fetch acct_list into Customer_ID , Account_ID  , Account_Description  ,Email  , Account_Officer_Name;
            exit when acct_list%notfound;

            dbms_output.put_line(Customer_ID ||'|'|| Account_ID  ||'|'|| Account_Description  ||'|'||Email  ||'|'|| Account_Officer_Name);

 end loop;
        close acct_list;
--var_account := Customer_ID ||'|'|| Account_ID  ||'|'|| Account_Description  ||'|'||Email  ||'|'|| Account_Officer_Name;

--    EXCEPTION
--    WHEN NO_DATA_FOUND THEN
--    var_account := null||'|'|| null||'|'|| null||'|'|| null||'|'|| null;

--   return var_account;
--   dbms_output.put_line(var_account);
END;
/

然后是我的php代码

    <?php include 'db.php';?>
<?php

/* The call */

$sql = 'BEGIN "COWRY"."CATIP_CRM__OFR_ACCT_LIST"(:crm_name); END;';

/* Parse connection and sql */
$foo = oci_parse($conn, $sql);

/* Binding Parameters */
oci_bind_by_name($foo, ':crm_name', $crm_name,50);


// Assign a value to the input 

$crm_name='Ezeilo Uzoamaka';
/* Execute */
$res = oci_execute($foo);

/* Get the output on the screen */
print_r($res, true);
?>

我不知道代码有什么问题,但没有显示任何结果。 或者也许php代码应该如何使用存储的过程从我的数据库中获取数据

0 个答案:

没有答案