尝试存储Oracle过程时收到错误,过程在未存储时工作

ruyhziif  于 2023-11-17  发布在  Oracle
关注(0)|答案(1)|浏览(152)
  • 嗨!我在存储ComplexProc的过程中遇到了问题。当我用“创建或替换”代码行替换为“删除”时,我可以让它工作,但是对于赋值,我需要能够将代码存储在一个名为ComplexProc的变量中。有什么想法吗?
CREATE OR REPLACE PROCEDURE ComplexProc () IS
    cursor emp is
    SELECT Ssn, Dno, Fname, Minit, Lname, Salary FROM Employee e WHERE e.Ssn = (SELECT Essn FROM Works_on wo
                                                                                                    WHERE Pno NOT IN ( SELECT p.Pnumber FROM Project p INNER JOIN Department d ON p.Dnum = d.Dnumber
                                                                                                                      INNER JOIN Employee e ON e.Dno = d.Dnumber WHERE e.Ssn = wo.Essn)
                                                                                                    AND Essn IN (SELECT Ssn FROM Employee e 
                                                                                                                WHERE e.Salary > ( SELECT Avg(Salary) FROM Employee e2 WHERE e.Dno = e2.DNo )
                                                                                                                AND (SELECT Count(Dependent_name) FROM Dependent d WHERE e.Ssn = d.Essn) >= 2)
                                                                                                    GROUP BY Essn HAVING Sum(Hours) >= 10);
                                                                                    
    emp_rec emp%rowtype;
    emp_NumDependents INT;
    emp_NonDepHours INT;
    emp_DepHours INT;

begin

    open emp;
    fetch emp into emp_rec; -- initial fetch

    emp_NumDependents := 0;
    while emp%found loop        -- still more data to fetch

        SELECT Count(Dependent_name) INTO emp_NumDependents FROM Dependent d WHERE d.Essn = emp_rec.Ssn;

        SELECT Sum(Hours) INTO emp_NonDepHours FROM Works_on wo
        WHERE wo.Pno NOT IN (SELECT p.Pnumber FROM Project p WHERE p.Dnum = emp_rec.Dno)
        AND wo.Essn = emp_rec.Ssn;

        SELECT Sum(Hours) INTO emp_DepHours FROM Works_on wo
        WHERE wo.Pno IN (SELECT p.Pnumber FROM Project p WHERE p.Dnum = emp_rec.Dno)
        AND wo.Essn = emp_rec.Ssn;
      
        dbms_output.put_line(emp_rec.Fname||' '||emp_rec.Minit||' '||emp_rec.Lname||' '||emp_rec.Salary||' '||emp_NumDependents||' '||emp_NonDepHours||' '||emp_DepHours);
        fetch emp into emp_rec;
    end loop;  
    close emp;
end;
/

commit;

字符串
谢谢你,谢谢
我通过将'Create or Replace'行替换为'Bullre'来使过程工作。然而,我需要将其存储在ComplexProc中以进行赋值。我尝试将'Is'更改为'As',添加和删除声明。然而,无论我更改多少次措辞,我都无法使其工作。

beq87vna

beq87vna1#

删除空括号:

CREATE OR REPLACE PROCEDURE ComplexProc IS

字符串

相关问题