Wednesday, October 31, 2007

阿联的处女秀

07年11月31日鬼节阿联处女秀作客奥兰多,雄鹿大败而归。

阿联9分3板6犯下场,3丢1抢,场上时间25:26,值得肯定!

易建联在处子战就首发出场,他的步子迈得比当初的姚明还快些。他的首次得分也比姚明来得快,在比赛开始了近3分钟后,他先是抢断得手,上篮命中,可惜被吹走步在先。在首节还有9分07秒时,他终于在右侧跳投命中,拿下NBA正式比赛的第一分,雄鹿以6-4领先。

易建联在第三节一开始就投篮命中,将比分扳平。四本节还有9分42秒时,雄鹿由易建联投中一球。易建联在比赛还有3分23秒时又投中一球,可惜此后他马上被吹第6次犯规,处子战就提前离场。




RECAP from NBA site:

ORLANDO, Fla.(AP) Rashard Lewis scored 26 points and Hedo Turkoglu had 24 to lift the sharp-shooting Orlando Magic to a 102-83 victory over the Milwaukee Bucks in the teams' season opener Wednesday night.

Behind Turkoglu and Lewis, making his Eastern Conference debut, the Magic buried Milwaukee from behind the arc. Orlando was 12-of-22, compared with 4-of-17 for the Bucks. Lewis was 4-of-5 and Turkoglu 3-for-5.

The Magic actually shot better from 3-point range (54 percent) than from the field (44 percent).

Michael Redd scored 25 points for Milwaukee and Bobby Simmons added 16. Yi Jianlian had nine points and three rebounds in 25 minutes in his debut, sitting for several stretches in foul trouble. Andrew Bogut finished with 11 rebounds.

Yi's first NBA statistic was a turnover, but he responded the next play by blocking Turkoglu's layup. The 7-footer scored his first NBA bucket about 30 seconds later on a 22-foot jumper.

Dwight Howard had 16 points and 12 rebounds. Perhaps most importantly for Orlando, he hit eight of 10 free throws.

Friday, October 26, 2007

ORCL - Lag/Lead Over

In normalized form, the data is display as the row format, such as the following:

12:28:14 PM SQL> select id_number, degree_code from degrees where id_number = 'xxxx';

ID_NUMBER DEGREE_CODE
---------- -----------
xxxxxxxxxx PHD
xxxxxxxxxx ENG
xxxxxxxxxx MSC

But we want the result displasy as one row as different columns, basically we want the data de-normlized.

A Little SQL

If we know the identity for the degree code then we can construct a SQL statement that will handle this type of query using Rotate/Pivot Query.

First we want to get such identity, so we use the windows over function to assign the row number to identify the degree code:

12:28:50 PM SQL> select id, row_number() over (partition by id order by code) rn, code from degrees;
ID RN CODE
---------- ---------- -----------
000000xxxx 1 NUSSS
000000xxx1 1 EDBSS
000000xxx2 1 MAAAA
000000xxx2 2 PHDSS
000000xxx3 1 BCZZZ
000000xxx3 2 SCESS

The we can change the row to colum display using the code shown below:
12:35:47 PM SQL>
12:40:20 PM SQL> select id,
2 (select d1.code from
3 (select id, row_number() over (partition by id order by code) rn, code
4 from table_name) d1
5 where d1.id = A.id and rn =1) degree1,
6 (select d1.code from
7 (select id, row_number() over (partition by id order by code) rn, code
8 from table_name) d1
9 where d1.id = A.id and rn =2) degree2,
10 (select d1.code from
11 (select id, row_number() over (partition by id order by code) rn, code
12 from table_name) d1
13 where d1.id = A.id and rn =3) degree3,
14 (select d1.code from
15 (select id, row_number() over (partition by id order by code) rn, code
16 from table_name) d1
17 where d1.id = A.id and rn =4) degree4
18 from (select id from table_name group by id) A
19 /

Then we achieve what we want!

But if you use the Lag/lead over analytic function, it is even better!

SQL> select id, d1, d2, d3, d4 from
2 (select id, sequence, degree_code d1, lead(degree_code,1) over (order by sequence) d2,
3 lead(degree_code,2) over (order by sequence) d3, lead(degree_code,3) over (order by sequence) d4
4 from tale_name
5 where id= '0000000xxx')
6 where sequence = 1
7 /

ID D1 D2 D3 D4
---------- ----- ----- ----- -----
0000000xxx PHD ENG MSC

SQL> here we go! Analytic functions rock for 80% case!

Tuesday, October 23, 2007

ORCL - REF CURSOR

A REF CURSOR is basically a data type. A variable created based on such a data type is generally called a cursor variable. A cursor variable can be associated with different queries at run-time. The primary advantage of using cursor variables is their capability to pass result sets between sub programs (like stored procedures, functions, packages etc.).

Example: %ROWTYPE with REF CURSOR:

declare
type r_cursor is REF CURSOR;
c_emp r_cursor;
er emp%rowtype;
begin
open c_emp for select * from emp;
loop
fetch c_emp into er;
exit when c_emp%notfound;
dbms_output.put_line(er.ename || ' - ' || er.sal);
end loop;
close c_emp;
The bold statements basically show the use of REF CURSOR.

Example of using REF as parameter in the sub-programs of a PL/SQL block:

Sub-programs can also be called sub-routines. These are nothing but the divisions of the main program. These divisions are named and are executed when they are called by name from the main program. They will not get executed unless they are called.

declare
type r_cursor is REF CURSOR;
c_emp r_cursor;

type rec_emp is record
(
name varchar2(20),
sal number(6)
);
procedure PrintEmployeeDetails(p_emp r_cursor) is
er rec_emp;

begin
loop
fetch p_emp into er;
exit when p_emp%notfound;
dbms_output.put_line(er.name || ' - ' || er.sal);
end loop;
end;
begin
for i in (select deptno,dname from dept)
loop
open c_emp for select ename,sal from emp where deptno = i.deptno;
dbms_output.put_line(i.dname);
dbms_output.put_line('--------------');
PrintEmployeeDetails(c_emp);
close c_emp;
end loop;
end;

There are 2 basic types: Strong ref cursor and weak ref cursor
For the strong ref cursor the returning columns with datatype and length need to be known at compile time.
For the weak ref cursor the structure does not need to be known at compile time.

The strong ref_cursor and until Oracle 9i also the weak-type need to be declared in a package structure lik this:

create or replace package REFCURSOR_PKG as
TYPE WEAK8i_REF_CURSOR IS REF CURSOR;
TYPE STRONG REF_CURSOR IS REF CURSOR RETURN EMP%ROWTYPE;
end REFCURSOR_PKG;

Since Oracle 9i you can use SYS_REFCURSOR as the type for the returning REF_CURSOR.

/** From Oracle 9 */
create or replace procedure test( p_deptno IN number
, p_cursor OUT SYS_REFCURSOR)
is .........

Cheers.

Friday, October 19, 2007

掀起腥风血雨,阿联!

北京时间10月19日《密尔沃基哨兵报》消息:雄鹿常规赛的首战将会在美国当地时间10月31日于奥兰多开始,随着时间的日益临近,易建联在球队训练营当中的进步非常神速。这样雄鹿全队上下都震惊不已,也让他们看到了这名来自中国的球员在篮球上的天赋和努力。按照目前的状态来看,他很可能会在常规赛掀起一场腥风血雨。

  “我非常喜欢他现在所做的这些,”球队主帅拉里-克里斯科维亚克说,“对于他的未来,我真的感到欢欣鼓舞,在他身上所体现出来的进步是非常引人瞩目的,他学东西的时候领悟得非常快。”

  “在进攻方面,他能够做到什么我自己都无法猜测,对于大多数新秀来说,不管你是来自澳大利亚、中国还是波兰,都不可能像他那样领悟得这么快。一旦他的(战术)思维都打通了的话,他在球场上就会更加轻松。我想他现在正向着自己的鼎盛状态前进。”

  易建联在过去的两场季前赛当中都先发出场,并且在场均约23分钟的时间内有9.3分7.4篮板的表现。不过他也有着全队最高的14次失误,同时命中率仅有37.8%而已。“他在篮球场上的时候串上跑下的非常活跃,并且越来越适应这里的环境。”球队中锋安德鲁-博古特评价易建联的时候说,“他用了一个月的时间才进入到比赛的状态当中,在之前他总是被媒体追着无法脱身,因此注意力不能完全集中起来,但是现在,他完全能够打好每一场球。”

  “在这里的训练非常激烈,而正是这样,才可以让我变得更加强壮,更加优秀。”易建联说。不过即使如此,他也从来没有对这些训练抱有太多的怨言,而是用自己的努力来迎接训练的挑战。

  虽然K帅对易建联的表现非常满意,但是并没有为他制定太高太苛刻的目标,而是努力的让他在新秀赛季的时候,慢慢找到自己打球的方式,适应NBA的争夺。“我已经有一个月的时间没有称赞他是一名全明星的料子了,”K帅说,“但是他目前确实正在变得越来越好,因为他总是很努力的训练,并且能够很好的阅读比赛。”

  “这就是六号新秀的潜质所在吧,你所想要从优秀球员中找寻的潜力都有,他是一个非常全面的球员,无论是技术、身高还是竞技能力,一个孩子不可能表现得非常完美,也不可能完全适应竞争,但是就我看来,在训练当中他每时每刻都在提高,因为竞争压力的存在而让他变得越来越优秀。”(球童)

Wednesday, October 17, 2007

ORCL - Functions

Oracle/PLSQL Functions
--------------------------------------------------------------------------------
Sign Function
In Oracle/PLSQL, the sign function returns a value indicating the sign of a number.
The syntax for the sign function is:
sign( number )
number is the number to test for its sign.
If number < 0, then sign returns -1.
If number = 0, then sign returns 0.
If number > 0, then sign returns 1.
Applies To: Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g
Example:
select (( SIGN( SIGN(NVL(tP.xsequence, 0) - NVL(PR.xsequence, 0)) + 1)
* NVL(tP.xsequence, 0)) +
( SIGN( SIGN(NVL(PR.xsequence, 0) - NVL(tP.xsequence,0)) + 1)
* NVL(PR.xsequence, 0) )) + 1, tp.xsequence, pr.xsequence
from tP, PR
where tP.P_Number = pr.p_number
--------------------------------------------------------------------------------

ORCL - Dependency

We have a table, and we want to find all procedures/objects do DML on this table.

If you use any IDE such as PL/SQL Developer, you will easily find any object which has anything to do with this table by checking Referenced by.

Oracle finds the object dependents with some internal tables. You can find the dependencies via selecting user_dependencies view or executing dbms_utility.get_dependency procedure.

Querying user_dependencies view:
SQL> select * from user_dependencies where referenced_name = 'ALARM_REMINDER_LOG';

Executing dbms_utility.get_dependency:
SQL> exec dbms_utility.get_dependency( 'TABLE', 'advance', 'pledge_reminder_log');

PL/SQL procedure successfully completed

Everything is from Oracle Data Dictionary? Right! Objects may have some dependencies on theirselves. When creating a package or a trigger you may need other objects. When compiling an object or executing an alter command, you make dependent objects invalid. On calling objects firstly Oracle check object status. If object s valid tehere is no problem. But if an object is invalid, Oracle tries to compile the dependent objects. If there is no problem, statement executed and object status will become valid.

Tuesday, October 16, 2007

易建联的体测数据


雄鹿公布了易建联的体测数据:

阿联的体重为246磅 (约111.6千克);

不穿鞋身高为6尺11 (约2.11米),穿鞋身高为7尺1/4寸 (约2.14米),所以他也是雄鹿最高的球员,Andrew Bogut 的穿鞋身高是7尺;

阿联的臂展为7尺3.5寸 (约2.22米),比 Bogut 长了0.5寸 (1.27厘米);

他的体脂肪率只有3.4,是全队最好的,全队次好的是 Michael Ruffin 的3.9。

雄鹿的力量与体能教练 Tim Wilson 还没让阿联进行力量测试,不过 Wilson 已给阿联制定了举重强化训练课,阿联说他上赛季在宏远每周举重两次。

“我们给他安排了计划,只要当天没有比赛,也不是星期天,他每天都会举重。”Wilson 说。“不过呢,虽然上周六我们有场季前赛,那天他想举重练习,所以也就 (破例) 练了。”

“他看起来喜欢举重。我想他知道举重会对他有好处的。”

阿联说,“我喜欢……我需要练习举重。”他也不忘开玩笑说,“我太瘦了。”

另外,雄鹿的器材管理员 Dwayne Wilson 说阿联穿的鞋子为17码,衣服则是3XL。

来源:[Milwaukee Journal Times]