我的PL / SQL代码不起作用:

时间:2016-07-13 04:55:22

标签: oracle plsql

这是我的代码:

CREATE OR REPLACE PROCEDURE log(repname in varchar2) AS 
  PACKAGE_NAME VARCHAR2,
  START_TIME DATE, 
  END_TIME DATE,
  STATUS;

BEGIN

  SELECT PACKAGE_NAME ,PRCS_START_TIME ,PRCS_END_TIME,STATUS
  FROM CONTCL_OWNER.PROCESSLOG 
  WHERE PACKAGE_NAME LIKE REPNAME
  ORDER BY PRCS_START_TIME
  WHERE ROW_NUMBER <=7;
END;

它给了我这些错误:

  

错误(2,60):PLS-00103:遇到以下其中一项时遇到符号“,”:: =。 (@%;非空范围默认字符

     

错误(3,1):PLS-00103:遇到以下其中一项时遇到符号“BEGIN”:long double ref char time timestamp interval date二进制国家字符nchar

     

错误(7,26):PLS-00103:当遇到以下情况之一时遇到符号“AND”:. (,* @%&amp; - +; / at for mod remaining rem asc desc || multiset

2 个答案:

答案 0 :(得分:0)

CREATE OR REPLACE PROCEDURE log(repname in varchar2) AS    
PACKAGE_NAME VARCHAR2,-- give size here like varchar2(50) 
START_TIME DATE,    
END_TIME DATE,   
STATUS;

BEGIN

 SELECT 
PACKAGE_NAME ,
PRCS_START_TIME ,
PRCS_END_TIME,
STATUS

-- add into clause to assign selected --values in variables 

FROM CONTCL_OWNER.PROCESSLOG    
WHERE PACKAGE_NAME LIKE '%REPNAME%' 
And ROW_NUMBER <=7   ORDER BY PRCS_START_TIME ; 
END;

答案 1 :(得分:0)

set serveroutput on;

CREATE OR REPLACE PROCEDURE Plog(p_repname CONTCL_OWNER.PROCESSLOG.PACKAGE_NAME%TYPE)
IS 
    CURSOR c_ctl IS
        SELECT PACKAGE_NAME    AS PNAME,
               PRCS_START_TIME AS PSTIME,
               PRCS_END_TIME   AS PETIME,
               STATUS
        FROM CONTCL_OWNER.PROCESSLOG 
        WHERE PACKAGE_NAME = p_repname
        AND ROWNUM <=7
        ORDER BY PRCS_START_TIME ASC;
BEGIN
    FOR v_ctl IN c_ctl LOOP
        DBMS_OUTPUT.PUT_LINE(v_ctl.PNAME  || ' - ' || 
                             v_ctl.PSTIME || ' - ' ||
                             v_ctl.PETIME || ' - ' ||
                             v_ctl.STATUS);
    /* ....
       HERE YOUR CODE LINE BY LINE
       ....
       ....
    */
    END LOOP;
END Plog;

您不能使用&#39; SELECT * INTO ......&#39;因为SELECT会返回很多行。