Tuesday, July 07, 2009

奇怪的Strange PL/SQL complier bug编译臭虫

今天终于完成了数据上载的智能修改, 就是说只修改数据有变化的列.

比如我们的库存表, 有50个列, 52% 的UPDATE仅修改"价格/price"一列.

可是遇到了一个极其古怪的臭虫, 如下所示, 一个简单的Loop循环, 漏掉了End Loop后面的分号";", 程序居然通过了编译,而且运行时也没有报错, 就是 End Loop 后面的语句被当成注释一样给跳过了. 这样的错误太难debug了, 幸好我充分的运用了code instrument技术, 几乎每一行代码都跟了一句debug (类似log4j), 很快找到了错误所在.
...

run_bulk_update;

FOR i in 1 .. lt_top_pattern.Count
Loop
run_bulk_update_tophit(p_hit_cols => lt_top_pattern(i));
End Loop ;

run_bulk_insert;
save_col_upd_pattern;
...

数据库版本是11.1.0.7.0, SunOS 5.10

Friday, July 03, 2009

可以少开会吗 Meetings are indispensable?

鄙人非常讨厌开会, 不过开会的时间是一个很好的打瞌睡休息时间.

除非你啥都不想干, 就去开会吧.

"Meetings are indispensable when you don't want to do anything."
-- John Kenneth Galbraith

Meetings (usually) suck. The traditional way of doing business includes company meetings throughout the day, taking an hour or more usually. This can eat up half of your day or more. Add to that individual meetings at lunch, or having drinks, or just a one-on-one in the office and you're meeting more than you re producing.

If you've sat through a lot of meetings, like I have, you know they're almost always useless. Sure, sometimes they're good, but most of the time they're boring, full of chit-chat or useless information, and really can be accomplished through a simple email or phone call. They're a waste of everyone's time, and worse yet, most people know it. And nothing changes.

有很多情况可以不用开会, 使用有效的替代方案:

Instead, learn to accomplish the tasks of a meeting through an email, a quick phone call, a quick and focused IM, an online group chat if necessary. Collaborate through online tools, such as those mentioned above. Keep meetings to a bare minimum. Sure, you still need to socialize with people, and have actual conversations, but boring and useless meetings aren't the best way to do that. If you control your company or division, do yourself and your company a favor by eliminating most of your meetings.

那么啥时候需要开会呢?

Only meeting after 3 round trip emails and the goal is still not clear.

以上摘自公司内部Email.

Wednesday, June 17, 2009

Cowichan River Tube Trip 漂流

一年一度的温哥华岛自然水域漂流又要开始啦! 欢迎留言报名. 跟我的http://twitter.com/mujiang也行.
在这里,您可以接受加拿大成人仪式, 品尝杂草(weed), 根据个人喜好选择,不存在任何强迫. 嘻嘻.

上甘岭河(Cowichan River)是我平生见到的最好玩的漂流, 水质纯天然,清澈,水量充足,安全,偶然有一些激流(一共两处),有惊无险,赶紧靠岸就行了,胆大的可以冒进. 去年鄙人躲了,今年一定要尝试一下激流速降.

Cowichan River Tube Trip

The Date

June 28th 2009

The Float

Skutz Falls to Marie Canyon - 2hr ride, not including optional time spent beached

Equipment needed

  1. Tube - If you don't have one, we can buy them at the local tire shop in Duncan for $20 or Zellers in Tillicum Mall has These for $24 (BESTEST TUBE EVEEER!!!!)
  2. Beverages - What ever you feel like drinking (NO GLASS BOTTLES ALLOWED)
  3. Cooler(s) - Communal, if anybody has a big cooler that would be great
  4. Cooler Tube - Gets blown up around the cooler to keep it a float and safe (also acts as an emergency spare)
  5. River Shoes - I use a old pair of runners, some sort of footware is a must(IMO)
  6. Rope - Or bungy to tie tubes to the trucks
  7. Sunscreen!!
  8. What ever else you might want to bring

The Time Line

  • 9 AM - Meet at ABE
  • 9:30 AM - Leave for Duncan
  • 10:15 AM - Buy Tires and Snacks if wanted
  • 10:30 AM - Buy Beverages and head off
  • 11:00ish AM - Start Tube ride
  • Enter time warp time can not be quantified

The Tubers

  1. Doug - Have Car will drive
  2. Megan - Has Car if needed
  3. Charlie - Will go if I can find someone take care of my puppy and my shin wound recovered.

Wednesday, June 10, 2009

scrum 群殴扭打

如果你们也在实施敏捷(Agile)软件开发,你就知道scrum是啥意思了, 就是在一个开发小组里面,每人每天早晨简短汇报工作进度.

每天早上的Scrum都会讲昨天干了什么,今天要干什么. 周一早上,我就说昨天我去沃尔玛采购了幼犬用品,今天继续开发在线库存系统的Database API.

大家沉默了三秒钟,突然开始集体爆笑. 原来每天的Scrum大伙都是来报到凑个数,没几个人关心别人干了什么.
就是做和尚撞钟,混个工分.

Friday, May 29, 2009

PL/SQL代码可以有多大size limit

PL/SQL程序块的最大尺寸是67108864 (2**26) DIANA节点, 主要是受shared memory pool的限制.
PL/SQL程序块包括(Package)包头,包体,独立存储过程,或者匿名程序块. eBay好像是统统使用匿名PL/SQL块.

但是对于DIANA节点,我们只能获取一个大概的数字,通过查询视图USER_OBJECT_SIZE,PARSED_SIZE列里面是"扁平化的flattened" DIANA节点数:


SQL> SELECT * FROM user_object_size WHERE name = 'PKG1';

NAME TYPE SOURCE_SIZE PARSED_SIZE CODE_SIZE ERROR_SIZE
----------------------------------------------------------------
PKG1 PACKAGE 46 165 119 0
PKG1 PACKAGE BODY 82 0 139 0


根据Tom和Tim(http://oracle-base.com/)的理想境界,去除Java/C/.Net等前端应用代码里面的所有SELECT/INSERT/UPDATE/DELETE/MERGE,把那些丑陋的SQL扔到九霄云外.
--不是说Java Developer不会写SQL, 而是他们的强项不在数据库. 模块化,专业分工,高效合作,

鄙人最近三个月奋发图强,努力工作,大力推行Database API, 消灭Java应用里面的SQL代码,书写了很多PL/SQL代码,有一个接近100K,编译一遍耗时数秒, 就开始担心最大尺寸问题. 结果PARSED_SIZE只有6115, 离67108864(64M)还差点远着哩.

当然鄙人也在认真学习Agile编程里面的Refactoring代码重构, 尽量将重复使用的代码段抽象成子过程,或者工具包.

参考:
Oracle® Database PL/SQL Language Reference
11g Release 1 (11.1)

Appendix C PL/SQL Program Limits
.

Sunday, May 24, 2009

Give and Take - IT Club聚会主题征集

眼看五月份要交白卷了, 转一篇我在维多利亚IT俱乐部的帖子:

鄙人有一个想法:

就是大伙罗列出你关心/感兴趣的主题, 和你能够共享/贡献的主题.
把答案发给木匠,然后鄙人整理筛选,协助GengLi 和 老Shan协调安排, 使以后的聚会更加有针对性.

好了, 举个例子, 比如 木匠的共享和兴趣:

贡献
----
*) 给IT老兵的六点建议
*) 数据库应用开发的糟糕模式与实践 Performance Anti-Patterns in Database-Driven
Applications
*) JDBC/.Net应用的高效数据库存取
*) GTD 时间管理

*) 自由泳 训练
*) 露营 + 密林狂奔
*) 训练小狗
*) Cowichan lake 轮胎漂流

感兴趣
-- -- ---
如和构建易于线性扩展的Web应用系统架构 (Scale out)
Agile项目管理
Agile软件开发流程

户外露营 + 密林狂奔
小狗训练
川菜烹饪
划船 及 安全


- MJ

Thursday, April 30, 2009

今日好图 流感传染途径How swine flu gets transmitted….

猪流感是这样传染的: