Oracle的PL_SQL的結構

來源:互聯網
上載者:User

標籤:declare   row   rowtype   data   bms   初始化   rom   char   type   

--PL/SQL的結構declare --聲明變數和常量關鍵字       v_name nvarchar2(20);       v_age integer;--常規變數聲明       v_product table_name.column_name%type;--根據表欄位的類型來生命變數       v_con constant int:=12;       v_convar constant nvarchar2(20):=‘常量‘;--聲明常量必須添加關鍵字constant       --聲明複合類型變數       type product_rec is record (       id int,       name table_name.column_name%type,       age number(10,2)       );              v_prod product_rec;              --利用rowtype聲明複合變數       --v_prod_d table_name%rowtype;              --索引表型別宣告       type productinfo is table of varchar2(40) index by pls_integer;--pls_integer和Binary_integer效果是一樣的,指定索引類型。       type producttype is table of table_name%rowtype index by binary_integer;       --生命索引表類型的變數       v_procinfo productinfo;       v_producttype producttype;              --vArray變數數組       type v_array is varray(100) of varchar2(20);              v_arry v_array:=v_array(‘1‘,‘2‘);--v_array(‘1‘,‘2‘)初始化兩個下標資料              begin--代碼執行的開始部分 v_name:=‘小馬‘;  select ‘xiaoxiao‘ into v_name from dual;  --複合變數的使用 v_prod.id:=1; v_prod.name:=‘小黑‘; v_prod.age:=34; --索引變數的使用 v_procinfo(1):=‘xixix‘; --給變長數組的賦值 v_arry(1):=‘this‘; v_arry(2):=‘this aa‘;   exception--程式出現異常執行部分when NO_DATA_FOUND then dbms_output.put_line(‘程式異常。‘);end;

Oracle的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.