必须声明ORA-06550标识符

时间:2015-08-06 19:19:13

标签: php sql oracle pdo plsql

我是Oracle / PLSQL的新手。我正在尝试写一个包。我正在使用Oracle SQL Developer。

SQL Developer中的一切看起来都很好,但是当我尝试通过PHP / PDO使用该包时,我得到以下内容:

  

警告:PDOStatement :: execute()[function.PDOStatement-execute]:   SQLSTATE [HY000]:常规错误:6550 OCIStmtExecute:ORA-06550:line   1,第7列:PLS-00201:标识符'SURVEY_TESTER.ADD_MBN_RECORD'必须   声明为ORA-06550:第1行第7列:PL / SQL:语句被忽略   (/core-php-src-5.2.5/php-5.2.5/ext/pdo_oci/oci_statement.c:146)in   第47行/home/robert/www/prod/htdocs/intra/__SURVEY_RECORD.php

我的包裹声明:

CREATE OR REPLACE 
PACKAGE SURVEY_TESTER AS 

  PROCEDURE ADD_MBN_RECORD(
    iMAILMONTH        IN MASTERBARCODEDNAMES14.MAILMONTH%TYPE,
    iZIPGROUP           IN MASTERBARCODEDNAMES14.ZIPGROUP%TYPE,
    iFIRST            IN MASTERBARCODEDNAMES14.FIRST%TYPE,
    iLAST               IN MASTERBARCODEDNAMES14.LAST%TYPE,
    iADDRESS            IN MASTERBARCODEDNAMES14.ADDRESS%TYPE,
    iCITY               IN MASTERBARCODEDNAMES14.CITY%TYPE,
    iST               IN MASTERBARCODEDNAMES14.ST%TYPE,
    iZIP                IN MASTERBARCODEDNAMES14.ZIP%TYPE,
    iSFDU               IN MASTERBARCODEDNAMES14.SFDU%TYPE,
    iSOURCE           IN MASTERBARCODEDNAMES14.SOURCE%TYPE,
    iSOURCECODE       IN MASTERBARCODEDNAMES14.SOURCECODE%TYPE,
    iNAMEMONTHMATCH   IN MASTERBARCODEDNAMES14.NAMEMONTHMATCH%TYPE,
    iCOMPLETED_SURVEY   IN MASTERBARCODEDNAMES14.COMPLETED_SURVEY%TYPE,
    iNSCFADDR           IN MASTERBARCODEDNAMES14.NSCFADDR%TYPE,
    iZIPADDRAPT       IN MASTERBARCODEDNAMES14.ZIPADDRAPT%TYPE
  );

  PROCEDURE ADD_RLI_RECORD(
    iMAILMONTH  IN RETAIL_LINE_ITEM.MAILMONTH%TYPE,
    iSPONSORID  IN RETAIL_LINE_ITEM.SPONSORID%TYPE,
    iDEALERID   IN RETAIL_LINE_ITEM.DEALERID%TYPE,
    iZIPCODE    IN RETAIL_LINE_ITEM.ZIPCODE%TYPE,
    iNAMES  IN RETAIL_LINE_ITEM.NAMES%TYPE,
    iZIPRATE    IN RETAIL_LINE_ITEM.ZIPRATE%TYPE,
    iZIPTOTAL   IN RETAIL_LINE_ITEM.ZIPTOTAL%TYPE,
    iMAILING    IN RETAIL_LINE_ITEM.MAILING%TYPE,
    iCRRT   IN RETAIL_LINE_ITEM.CRRT%TYPE
  );

END SURVEY_TESTER;
/

我的包裹身体:

CREATE OR REPLACE PACKAGE BODY SURVEY_TESTER AS

  PROCEDURE ADD_MBN_RECORD(
    iMAILMONTH        IN MASTERBARCODEDNAMES14.MAILMONTH%TYPE,
    iZIPGROUP           IN MASTERBARCODEDNAMES14.ZIPGROUP%TYPE,
    iFIRST            IN MASTERBARCODEDNAMES14.FIRST%TYPE,
    iLAST               IN MASTERBARCODEDNAMES14.LAST%TYPE,
    iADDRESS            IN MASTERBARCODEDNAMES14.ADDRESS%TYPE,
    iCITY               IN MASTERBARCODEDNAMES14.CITY%TYPE,
    iST               IN MASTERBARCODEDNAMES14.ST%TYPE,
    iZIP                IN MASTERBARCODEDNAMES14.ZIP%TYPE,
    iSFDU               IN MASTERBARCODEDNAMES14.SFDU%TYPE,
    iSOURCE           IN MASTERBARCODEDNAMES14.SOURCE%TYPE,
    iSOURCECODE       IN MASTERBARCODEDNAMES14.SOURCECODE%TYPE,
    iNAMEMONTHMATCH   IN MASTERBARCODEDNAMES14.NAMEMONTHMATCH%TYPE,
    iCOMPLETED_SURVEY   IN MASTERBARCODEDNAMES14.COMPLETED_SURVEY%TYPE,
    iNSCFADDR           IN MASTERBARCODEDNAMES14.NSCFADDR%TYPE,
    iZIPADDRAPT       IN MASTERBARCODEDNAMES14.ZIPADDRAPT%TYPE
  ) IS
  BEGIN
    INSERT INTO MASTERBARCODEDNAMES14 (
        MAILMONTH,
        ZIPGROUP,
        FIRST,
        LAST,
        ADDRESS,
        CITY,
        ST,
        ZIP,
        SFDU,
        SOURCE,
        SOURCECODE,
        NAMEMONTHMATCH,
        COMPLETED_SURVEY,
        NSCFADDR,
        ZIPADDRAPT
    ) VALUES (
        iMAILMONTH, 
        iZIPGROUP, 
        iFIRST, 
        iLAST, 
        iADDRESS, 
        iCITY, 
        iST, 
        iZIP, 
        iSFDU, 
        iSOURCE, 
        iSOURCECODE, 
        iNAMEMONTHMATCH, 
        iCOMPLETED_SURVEY, 
        iNSCFADDR, 
        iZIPADDRAPT
    );
  END ADD_MBN_RECORD;


  PROCEDURE ADD_RLI_RECORD(
    iMAILMONTH  IN RETAIL_LINE_ITEM.MAILMONTH%TYPE,
    iSPONSORID  IN RETAIL_LINE_ITEM.SPONSORID%TYPE,
    iDEALERID   IN RETAIL_LINE_ITEM.DEALERID%TYPE,
    iZIPCODE    IN RETAIL_LINE_ITEM.ZIPCODE%TYPE,
    iNAMES  IN RETAIL_LINE_ITEM.NAMES%TYPE,
    iZIPRATE    IN RETAIL_LINE_ITEM.ZIPRATE%TYPE,
    iZIPTOTAL   IN RETAIL_LINE_ITEM.ZIPTOTAL%TYPE,
    iMAILING    IN RETAIL_LINE_ITEM.MAILING%TYPE,
    iCRRT   IN RETAIL_LINE_ITEM.CRRT%TYPE
  ) IS
  BEGIN
    INSERT INTO RETAIL_LINE_ITEM (
        MAILMONTH, 
        SPONSORID, 
        DEALERID, 
        ZIPCODE, 
        NAMES, 
        ZIPRATE, 
        ZIPTOTAL, 
        MAILING, 
        CRRT
    ) values (
        iMAILMONTH, 
        iSPONSORID, 
        iDEALERID, 
        iZIPCODE, 
        iNAMES, 
        iZIPRATE, 
        iZIPTOTAL, 
        iMAILING, 
        iCRRT
    );
  END ADD_RLI_RECORD;

END SURVEY_TESTER;
/

而且,这是我的PHP的要点。假设生成的SQL没问题。

$sql = "begin SURVEY_TESTER.ADD_".$table."_RECORD(:".implode(", :", array_keys($data))."); end;";

这是一个var_dump。如果它有帮助。

string 'begin SURVEY_TESTER.ADD_RLI_RECORD(:mailmonth, :sponsorid, :dealerid, :zipcode, :names, :ziprate, :ziptotal, :mailing, :crrt); end;' (length=131)

array
  ':mailmonth' => string '0715' (length=4)
  ':sponsorid' => string '121266' (length=6)
  ':dealerid' => string 'COFL' (length=4)
  ':zipcode' => string '34683' (length=5)
  ':names' => string '100' (length=3)
  ':ziprate' => string '0.56' (length=4)
  ':ziptotal' => string '24.75' (length=5)
  ':mailing' => string '201507' (length=6)
  ':crrt' => string 'All' (length=3)

我做错了什么?

2 个答案:

答案 0 :(得分:1)

我认为代码本身很好。
但是您的包的设置可能是问题所在。

CREATE OR REPLACE PACKAGE BODY NameIt AS 
    PROCEDURE AddOne()
    AS
    BEGIN
        BEGIN
            # Insert into table. 
        EXCEPTION
            # What if the value is already inserted? 
        END;
    END;

    PROCEDURE AddTwo()
    AS
    BEGIN
        BEGIN
            # Insert into table. 
        EXCEPTION
            # What if the value is already inserted? 
        END;
    END;
END;
/

答案 1 :(得分:0)

答案来自@Wolf的评论

  

您需要以拥有此软件包的用户身份进行连接,或者   授予执行SURVEY_TESTER到your_connection_user;。因为   默认是编译为authid current_user,您还需要授予   另一个连接的底层对象(表,视图等)   用户。