Oracle PL/SQL塊

來源:互聯網
上載者:User

Oracle PL/SQL塊

PL/SQL塊 簡介 :PL/SQL是 Procedure Language & Structured Query Language 的縮寫,是Oracle公司對標準資料庫語言的擴充

PL/SQL塊 文法:

declare
    <<聲明部分>>
begin
    <<邏輯部分>>
    exception
      when other then
          <<異常處理部分>>             
end;

PL/SQL塊文法

注意:異常處理與其他語言中的異常處理類似  順序是從低到高

Oracle常用異常處理
名稱 說明
other 包括所有異常(最進階別異常)
value_error 值異常
no_data_found 沒有找到資料
too_many_rows 資料太多

聲明PL/SQL 包

文法:

--包 聲明  類似介面
create or replace package 包名
as
    <<聲明部分  可以為變數  函數  預存程序 等>>
end

--包 實現  實現介面
create or replace package body 包名
as
    <<實現聲明部分 函數 預存程序>>
end

PL/SQL 包

聲明PL/SQL 函數

文法:

 create or replace function 方法名 return 傳回值
 as
        <<聲明變數>>
 begin
        <<邏輯體>>       
 end;

--------------------------------------分割線 --------------------------------------

rlwrap - 解決Linux下SQLPLUS退格、上翻鍵亂碼問題

SQLPLUS spool 到動態記錄檔名

Oracle SQLPLUS提示符設定

通過設定SQLPLUS ARRAYSIZE(行預取)加快SQL返回速度

PL/SQL Developer實用技巧分享

--------------------------------------分割線 --------------------------------------

相關文章

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.