Oracle陣列使用以及PLSQL操作記錄
----------------------------固定長度陣列
declare
type intarray is varray(30) of varchar2(100);
var_arr intarray := intarray('a','b','c','d');
begin
for i in 1..var_arr.count
loop
dbms_output.put_line(var_arr(i));
end loop;
end;
---------------------------未知長度陣列
declare
type vararray is table of varchar2(50) index by binary_integer;
var_arr vararray;
begin
for i in 1..15 loop
var_arr(i) := i+10;
end loop;
dbms_output.put_line('Count: '|| var_arr.count);
dbms_output.put_line(var_arr(11));
end;
------------------------自定義1
declare
var_phone varchar2(100);
idex int;
nextIdex int;
iphone varchar2(100);
begin
var_phone := '10000,10001,10002,10003,10004';
dbms_output.put_line(var_phone);
idex := 0;
nextIdex := 1;
while nextIdex > 0 loop
nextIdex := instr(var_phone, ',', idex+1);
dbms_output.put_line(idex || ' --- ' || nextIdex);
if nextIdex > 0 then
iphone := substr(var_phone, idex+1, nextIdex-idex-1);
else
iphone := substr(var_phone, idex+1);
end if;
idex := nextIdex;
dbms_output.put_line(iphone);
end loop;
end;
------------------- 自定義2 使用陣列
declare
var_phone varchar2(100) := '1000';--'10000,10001,10002,10003,10004';
idex int;
nextIdex int;
type charArray is table of varchar2(100) index by binary_integer;
phone_arr charArray;
arrCount int := 1;
begin
dbms_output.put_line(var_phone);
idex := 0;
nextIdex := 1;
while nextIdex > 0 loop
nextIdex := instr(var_phone, ',', idex+1);
dbms_output.put_line(idex || ' --- ' || nextIdex);
if nextIdex > 0 then
phone_arr(arrCount) := substr(var_phone, idex+1, nextIdex-idex-1);
arrCount := arrCount + 1;
else
phone_arr(arrCount) := substr(var_phone, idex+1);
end if;
idex := nextIdex;
--dbms_output.put_line();
end loop;
for i in 1..phone_arr.count loop
dbms_output.put_line(phone_arr(i));
end loop;
end;
------------------------------------------>>
轉載於:http://johnny-gz.iteye.com/blog/1751754
declare
type intarray is varray(30) of varchar2(100);
var_arr intarray := intarray('a','b','c','d');
begin
for i in 1..var_arr.count
loop
dbms_output.put_line(var_arr(i));
end loop;
end;
---------------------------未知長度陣列
declare
type vararray is table of varchar2(50) index by binary_integer;
var_arr vararray;
begin
for i in 1..15 loop
var_arr(i) := i+10;
end loop;
dbms_output.put_line('Count: '|| var_arr.count);
dbms_output.put_line(var_arr(11));
end;
------------------------自定義1
declare
var_phone varchar2(100);
idex int;
nextIdex int;
iphone varchar2(100);
begin
var_phone := '10000,10001,10002,10003,10004';
dbms_output.put_line(var_phone);
idex := 0;
nextIdex := 1;
while nextIdex > 0 loop
nextIdex := instr(var_phone, ',', idex+1);
dbms_output.put_line(idex || ' --- ' || nextIdex);
if nextIdex > 0 then
iphone := substr(var_phone, idex+1, nextIdex-idex-1);
else
iphone := substr(var_phone, idex+1);
end if;
idex := nextIdex;
dbms_output.put_line(iphone);
end loop;
end;
------------------- 自定義2 使用陣列
declare
var_phone varchar2(100) := '1000';--'10000,10001,10002,10003,10004';
idex int;
nextIdex int;
type charArray is table of varchar2(100) index by binary_integer;
phone_arr charArray;
arrCount int := 1;
begin
dbms_output.put_line(var_phone);
idex := 0;
nextIdex := 1;
while nextIdex > 0 loop
nextIdex := instr(var_phone, ',', idex+1);
dbms_output.put_line(idex || ' --- ' || nextIdex);
if nextIdex > 0 then
phone_arr(arrCount) := substr(var_phone, idex+1, nextIdex-idex-1);
arrCount := arrCount + 1;
else
phone_arr(arrCount) := substr(var_phone, idex+1);
end if;
idex := nextIdex;
--dbms_output.put_line();
end loop;
for i in 1..phone_arr.count loop
dbms_output.put_line(phone_arr(i));
end loop;
end;
------------------------------------------>>
轉載於:http://johnny-gz.iteye.com/blog/1751754
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29119536/viewspace-1149565/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PLSQL Language Referenc-PL/SQL集合和記錄-可變陣列-正確地使用可變陣列SQL陣列
- PLSQL Language Referenc-PL/SQL集合和記錄-關聯陣列-正確地使用關聯陣列SQL陣列
- PLSQL Language Referenc-PL/SQL集合和記錄-關聯陣列SQL陣列
- PLSQL Language Referenc-PL/SQL集合和記錄-關聯陣列-宣告關聯陣列常量SQL陣列
- plsql陣列學習SQL陣列
- plsql 陣列的用法SQL陣列
- 記一次陣列操作:陣列 A 根據陣列 B 排序陣列排序
- JavaScript的字串、陣列以及DOM操作總結JavaScript字串陣列
- MDSL記錄儀的陣列陣列
- Oracle陣列的使用Oracle陣列
- Java陣列宣告建立和使用以及多維陣列、Arrays類、稀疏陣列Java陣列
- javascript中常用的陣列操作方法,以及是否會改變原始陣列JavaScript陣列
- 陣列操作陣列
- plsql記錄型別SQL型別
- [轉]Oracle陣列的使用Oracle陣列
- vue陣列操作遇到坑-關於陣列操作Vue陣列
- 陣列的reduce操作+物件陣列的map操作陣列物件
- oracle日誌操作記錄Oracle
- 【筆記】oracle 陣列實現筆記Oracle陣列
- oracle單條sql與plsql rowid插入記錄小記OracleSQL
- PLSQL Language Referenc-PL/SQL集合和記錄-使用記錄更新行SQL
- 【面試系列】之五:關於字串以及陣列的操作面試字串陣列
- javascript陣列操作JavaScript陣列
- Numpy陣列操作陣列
- Scala陣列操作陣列
- Jquery陣列操作jQuery陣列
- JavaScript 陣列操作JavaScript陣列
- Oracle中陣列使用方法Oracle陣列
- php 操作 MongoBb 使用記錄PHPGo
- PHP xml 轉陣列 陣列轉 xml 操作PHPXML陣列
- java之陣列的索引,排序以及二維陣列Java陣列索引排序
- 對陣列的操作陣列
- JS常用陣列操作JS陣列
- JavaScript陣列常用操作JavaScript陣列
- JS中陣列操作JS陣列
- 陣列的操作(2)陣列
- Scala的陣列操作陣列
- 陣列的基本操作陣列