mld@ORCL> create table dept
2 ( deptno number(2),
3 dname varchar2(14),
4 loc varchar2(13),
5 last_mod timestamp with time zone
6 default systimestamp
7 not null,
8 constraint dept_pk primary key(deptno)
9 )
10 /

表已创建。
mld@ORCL> insert into dept( deptno, dname, loc )
2 select deptno, dname, loc
3 from scott.dept;

已创建4行。

mld@ORCL> commit;

提交完成。

mld@ORCL> variable deptno number
mld@ORCL> variable dname varchar2(14)
mld@ORCL> variable loc varchar2(13)
mld@ORCL> variable last_mod varchar2(50)
mld@ORCL> begin
2 :deptno := 10;
3 select dname, loc, last_mod
4 into :dname,:loc,:last_mod
5 from dept
6 where deptno = :deptno;
7 end;
8 /

PL/SQL 过程已成功完成。

mld@ORCL> select :deptno dno, :dname dname, :loc loc, :last_mod lm
2 from dual;

DNO DNAME LOC
---------- -------------------------------- --------------------------------
LM
--------------------------------------------------------------------------------
--------------------
10 ACCOUNTING NEW YORK
05-5月 -09 09.48.21.625000 下午 +08:00


mld@ORCL> update dept
2 set dname = initcap(:dname),
3 last_mod = systimestamp
4 where deptno = :deptno
5 and last_mod = to_timestamp_tz(:last_mod);

已更新 1 行。

mld@ORCL> /

已更新0行。

posted on 2009-05-05 22:23
donnie 阅读(161)
评论(0) 编辑 收藏 所属分类:
database