Oracle中如何建立查詢資訊的預存程序!

來源:互聯網
上載者:User

平時用慣了MS-SQL2000,猛一用Oracle還真有點不適應。今天寫一個查詢語句,寫好後,發現太長了。從效能和方便實用考慮,決定將其交給預存程序來實現。 思路是有了,可是還真不知道在Oracle上怎麼寫呢!(目前還沒有踏實的學習Oracle的文法手冊,都是生硬的哪來用的!)

 開始,模仿現有的預存程序將其文法結構給加上去。

格式如下:

create or replace procedure SP_ZY_hzqdyl(

                      V_inpatient_id IN number,                   

                                         ) is

begin
 SELECT * from A where c= V_inpatient_id
end

哈哈!!完工了!PL/SQL執行,錯誤!

怎麼回事呢!!

後來請教了同事才明白,在Oracle中查詢資料時要使用遊標!

create or replace procedure SP_ZY_hzqdyl(


                      V_inpatient_id IN number,                    

                      C_Cur                   out      pa_zy.c_zy                                          
                                         ) is

begin
 Open C_Cur for
 SELECT * from A where c= V_inpatient_id
end

在Pl/Sql下執行,成功!

今天算是學了點基礎知識!


 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.