博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

CLEANER

如果你的工作,机器也可以做。那总有一天,你也要变成机器。
   yuechaotian.cublog.cn
关于作者  
name:yuechaotian
employment:coder
age:25
from:NEU
about me:a retardate
email:yuechaotian(at)gmail.com
msn:yuechaotian(at)hotmail.com

我的分类  




DML and Record
DML 操作中,可以直接使用记录,来简化我们的编码。
 
1. insert
 
SQL> select * from test1;
 
A                             B
-------------------- ----------
test1                        99
test1                      1010
test1                      1111
test1                      1212
test1                      1313
 
SQL> declare
  2   
rec_test1 test1%rowtype;
  3  begin
  4    rec_test1.a := 'yuechaotian';
  5    rec_test1.b := '8888';
  6   
insert into test1 values rec_test1;
  7    commit;
  8  end;
  9  /
 
PL/SQL 过程已成功完成。
 
SQL> select * from test1;
 
A                             B
-------------------- ----------
test1                        99
test1                      1010
test1                      1111
test1                      1212
test1                      1313
yuechaotian                8888
 
已选择6行。
 
在 forall 中也可以这样使用。
 
 
2. upate
 
SQL> declare
  2    rec_test1 test1%rowtype;
  3  begin
  4    rec_test1.a := 'tianyc';
  5    rec_test1.b := '6666';
  6    update test1
  7       set row = rec_test1
  8     where a = 'yuechaotian';
  9    commit;
 10  end;
 11  /
 
PL/SQL 过程已成功完成。
 
SQL> select * from test1;
 
A                             B
-------------------- ----------
test1                        99
test1                      1010
test1                      1111
test1                      1212
test1                      1313
tianyc                         6666
 
已选择6行。
 
row 是关键字,表示更新整行。

 发表于: 2008-06-07,修改于: 2008-06-07 17:10 已浏览388次,有评论0条 推荐 投诉

  网友评论

  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:0.83063

京ICP证041476号