仔细看吧,相信你有读懂他的能力!!The %TYPE attribute provides the datatype of a variable, constant, or
database column. In the following example, %TYPE provides the datatype
of a variable: credit REAL(7,2);
debit credit%TYPE; Variables and constants declared using %TYPE are treated like those
declared using a datatype name. For example, given the previous
declarations, PL/SQL treats "debit" like a REAL(7,2) variable. The next example shows that a %TYPE declaration can include an
initialization clause: balance NUMBER(7,2);
minimum_balance balance%TYPE := 10.00; The %TYPE attribute is particularly useful when declaring variables
that refer to database columns. You can reference a table and column,
or you can reference a schema, table, and column, as the following
example shows: my_dname scott.dept.dname%TYPE; Using %TYPE to declare "my_dname" has two advantages. First, you
need not know the exact datatype of "dname." Second, if the database
definition of "dname" changes, the datatype of "my_dname" changes
accordingly at run time. Note, however, that a NOT NULL column constraint does not apply to
variables declared using %TYPE. In the next example, even though the
database column "empno" is defined as NOT NULL, you can assign a null to the variable "my_empno": DECLARE
my_empno emp.empno%TYPE;
...
BEGIN
my_empno := NULL; -- this works
...
END;
database column. In the following example, %TYPE provides the datatype
of a variable: credit REAL(7,2);
debit credit%TYPE; Variables and constants declared using %TYPE are treated like those
declared using a datatype name. For example, given the previous
declarations, PL/SQL treats "debit" like a REAL(7,2) variable. The next example shows that a %TYPE declaration can include an
initialization clause: balance NUMBER(7,2);
minimum_balance balance%TYPE := 10.00; The %TYPE attribute is particularly useful when declaring variables
that refer to database columns. You can reference a table and column,
or you can reference a schema, table, and column, as the following
example shows: my_dname scott.dept.dname%TYPE; Using %TYPE to declare "my_dname" has two advantages. First, you
need not know the exact datatype of "dname." Second, if the database
definition of "dname" changes, the datatype of "my_dname" changes
accordingly at run time. Note, however, that a NOT NULL column constraint does not apply to
variables declared using %TYPE. In the next example, even though the
database column "empno" is defined as NOT NULL, you can assign a null to the variable "my_empno": DECLARE
my_empno emp.empno%TYPE;
...
BEGIN
my_empno := NULL; -- this works
...
END;
解决方案 »
- 为什么a表里的所有数据被更新?
- SQL*net more data to client等待事件导致ora-03113错误
- oracle改变表空间
- win2000server操作系统崩溃了,现在想重装系统,怎么让oracle里的数据不丢失呢?
- 怎样输入一个字符串赋给一个变量?
- 游标的简单问题
- 请问操作oracle的软件plsql,在输入一段过程后,有一个"/"加回车,请问"/"是什么意思?
- about dynamic sga feature in oracle9i
- java向Oracle9I数据库中插入数据
- 工作中遇到的sql查询问题,求大神帮个忙,谢谢您
- select查詢的group by為變量怎麼辦?在線等,急!
- 我发觉ORACLE的错误码,有些时ORA开头的,有些是TNS开头的,有什么区别吗?还有以其它开头的吗?在哪里可以找到所有的错误码?
就举上面的例子:
定义v_content类型,类型与comm_services表的SERVICE_CONTENT字段的类型相同