oracle中函數和過程沒有參數問題

來源:互聯網
上載者:User

上次遇到一個小小的問題,準確的說是設計上的缺陷,先看看問題在哪裡,

3、針對DEPT和EMP表,查詢出下面格式的結果並要求按部門編號和工資降序排列。【過程列印】
      部門名稱  員工姓名  工資

create or replace procedure up_getde(v_did number)
as
cursor mycur is select d.dname as dname ,e.ename as ename,e.sal as sal
from dept d ,emp e
where d.deptno = e.deptno
order by d.deptno ,e.sal desc;

begin

for i in mycur loop
   dbms_output.put_line(i.dname || '    ' || i.ename ||'    '|| i.sal);
end loop;
end;
    

最後執行過程: exec up_getde(0);

 

有一個沒有意義的參數v_did ,多餘的,今天發現瞭解決的辦法,,

如果函數和預存程序沒有參數,則函數名和預存程序名後面不應該有擴號(),否則會報告函數有編譯錯誤。

而調用時時要加上()的

如下select e.eid ,e.uf_getYearSal() from newstaff e where e.eid=1

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.