簡單的Oracle預存程序的建立方法

來源:互聯網
上載者:User

 來源:網路/責編:編程入門 作者:不詳

  串連到:

  Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

  With the Partitioning, OLAP and Oracle Data Mining options

  JServer Release 9.2.0.1.0 - Production

  SQL> create or replace procedure get_news(
   2 aid in varchar2,atitle in varchar2)
   3 as
   4 begin
   5 select * from cf_news
   6 end;
   7 /

  警告: 建立的過程帶有編譯錯誤。

  SQL> create or replace procedure get_news(
   2 aid in varchar2 ,atitle in varchar2)
   3 as
   4 beging
   5 /

  警告: 建立的過程帶有編譯錯誤。

  SQL> create or replace procedure get_news(
   2 aid in varchar2)
   3 as
   4 begin
   5 select * from cf_news;
   6 end;
   7 /

  警告: 建立的過程帶有編譯錯誤。

  SQL> create or replace procedure get_news
   2 as
   3 begin
   4 select * from cf_news;
   5 end;
   6 /

  警告: 建立的過程帶有編譯錯誤。

  SQL> show errors;
   PROCEDURE GET_NEWS 出現錯誤:
  
   LINE/COL ERROR
   -------- -------------------------------------
   4/1   PLS-00428: 在此 SELECT 語句中缺少 INTO 子句
   SQL> create or replace procedure get_news
   2 as
   3 aa number;
   4 begin
   5 select count(*) into aa from cf_news;
   6 end;
   7 /

  過程已建立。

  SQL> create or replace procedure get_news
   2 as
   3 aa number;
   4 begin
   5 select count(*) into aa from cf_news;
   6 dbms_outpub.put_line('aa='||aa);
   7 end;
   8 /

  警告: 建立的過程帶有編譯錯誤。

  SQL> show errors;
   PROCEDURE GET_NEWS 出現錯誤:
  
   LINE/COL ERROR
   -------- -----------------------------------------
   6/1   PLS-00201: 必須說明標識符 'DBMS_OUTPUB.PUT_LINE'
   6/1   PL/SQL: Statement ignored
   SQL> create or replace procedure get_news
   2 as
   3 aa number;
   4 begin
   5 select count(*) into aa from cf_news;
   6 dbms_output.put_line('aa='||aa);
   7 end;
   8 /

  過程已建立。

  SQL> set serverout on;
   SQL> execute get_news;
   aa=3

  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.