Oracle数组使用以及PLSQL操作记录
来源:互联网 发布:手机测量长度软件 编辑:程序博客网 时间:2024/06/05 15:13
----------------------------固定长度数组
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;
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;
1 0
- Oracle数组使用以及PLSQL操作记录
- 今天使用plsql操作oracle数据库使用replace函数以及遇到表死锁解决方法
- PLSQL:oracle记录类型
- ORACLE监听配置以及使用plsql连接oracle
- PLSQL Developer 使用记录
- oracle安装环境搭建以及PLSQL Developer使用
- Oracle 集合 plsql记录表
- Oracle 基本 以及 plsql 语句
- 如何不用oracle client直接使用plsql远程连接oracle数据库以及需要注意的事项
- Oracle:关于安装oracle中踩得坑以及plsql的安装使用中的坑
- PLSQL连接Oracle数据库配置简要记录
- plsql使用精简oracle客户端
- 使用plsql developer连接oracle
- 使用plsql创建oracle表
- Oracle plsql developer 使用技巧
- Oracle基本PLSQL的使用
- oracle 存储过程以及plsql语句块
- 不装oracle客户端使用plsql,以及中文乱码问号问题
- Android 样式和主题(style&theme)
- 什么是数字签名?
- web所有标签网址
- HDU-5889-Barricade【2016青岛网络】【spfa】【最小割】
- html5 make some noise
- Oracle数组使用以及PLSQL操作记录
- 在kindle阅读PDF的较好的解决方法
- 【UVa1625】颜色的长度
- 全选反选
- 如何退出Activity?如何安全退出已调用多个Activity的Application?
- 回文字符串
- .net mvc 微信公众号 自定义菜单
- Android Glide加载图片自动适应宽度
- SQL SERVER 在dos中执行多个SQL脚本