星期二, 十月 17, 2006

plsql读书笔记2

1,BINARY_FLOAT 1.5f
BINARY_DOUBLE 3.00005d

2,identifier [CONSTANT] datatype [NOT NULL] [:= | DEFAULT expr]

3,emp.ename%TYPE
4,复合变量
a,PL/SQL纪录
DECLARE
TYPE type_name IS RECORD(
name emp.ename%TYPE,
title emp.etitle%TYPE,
);
record_name typename;
BEGIN
SELECT ename,etitle INTO record_name
FROM emp WHERE empno=42332;
dbms_output.put_line('name'||emp_record.name);
END;
b,PL/SQL表
下标没有上下限
DECLARE
TYPE type_name IS TABLE OF emp.ename%TYPE
INDEX BY BINARY_INTEGER;
table_name type_name;
BEGIN
SELECT ename INTO table_name(-1) FROM emp
WHERE empno = 123;
dbms_output.put_line('name'||table_name(-1));
END;
c,嵌套表(Nested Table)
CREATE OR REPLACE TYPE type_name AS OBJECT(
name VARCHER2(10), title NUMBER(6,2),date DATE);
ps:使用嵌套表作为表列时应指定其存储表
eg:NESTED TABLE nested_table STORE AS nested_table_name;
d,VARRAY(变长数组)
VARRAY的元素个数是有限制的
CREATE TYPE type_name AS OBJECT(
title VARCHER2(20),date DATE);

CREATE TYPE varray_name IS VARRAY(20) OF type_name;

没有评论: