oracle儲存過程中陣列申明和遍歷

2021-07-05 06:59:18 字數 606 閱讀 3111

create or replace

procedure test as

--申明陣列型別

type t_test is table of varchar2(9);

test t_test:=t_test('a','b','c','d','e','f','g','h','j','k','l');

begin

--遍歷陣列,將遍歷得到的資料插入到aa表中

for i in 1 .. test.count loop

--while迴圈
while test(i)='a' loop

insert into aa(hongyan) values('aaaa');

end loop;

insert into aa(hongyan) values(test(i));

commit;

end loop;

end;

注意:陣列的必須申明,oracle中的陣列就是一張表;遍歷陣列的for條件;for迴圈中嵌入while迴圈

oracle儲存過程中is和as區別

一直糾結於儲存過程的is與as最近在網上查了巨多資料,總結如下 在儲存過程 procedure 和函式 function 中沒有區別 在檢視 view 中只能用as不能用is 在游標 cursor 中只能用is不能用as。從其定義也可以看出沒什麼區別,要是有估計暫時也很少有人發下 create or...

oracle儲存過程中如何使用陣列 附範例

原文 在pl sql中是沒有陣列 array 概念的。但是如果程式設計師想用array的話,就得變通一下,用type 和table of record來代替多維陣列,一樣挺好用的。emp type 就好象乙個table 中的一條record 一樣,裡面有id,name,gender等。emp typ...

儲存過程中呼叫儲存過程

use northwind go 儲存過程1 功能 通過員工firstname inputempfirstname 獲得 員工id outid if exists select name from sysobjects where name p getempleeidbyname and type ...