木匠的微型博客 Charlie Twitter

    follow me on Twitter

    Tuesday, February 05, 2008

    在维多利亚Oracle用户组学到的东西

    上周四下午, 第一次参加了Victoria Oracle Users Group
    组织的技术交流活动. 题目是 Database Gems: 9i, 10g, and 11g.

    VicOUG 请来了著名Oracle 技术网站的http://www.psoug.org/的作者: Dan Morgan,
    --
    最常用的是
    Morgan's Library http://www.psoug.org/library.html, 可以找到各种语法和函数用例.
    这个伙计自称因为人员好, 被评为Oracle Ace Director.

    言归正传, 以下是我学到的3点,

    1)
    ALTER SYSTEM SET PLSQL_WARNINGS='ENABLE:ALL';
    建议在所有的开发(Development)及测试(Test)环境设置.

    有啥好处呢? 编译PL/SQL的时候,给出有用的警告信息.
    a) 严重问题, 比如参数混淆 (这点我还没有理解, 需要一个示例)
    b) 性能问题, 一个INSERT语句,传递一个VARCHAR2值给一个NUMBER列
    c) 提示信息, 比如有一段代码 永远不会被执行

    详细说明, 请参考:
    Oracle® Database PL/SQL Language Reference
    11g Release 1 (11.1)
    - 第十一章: 11 Handling PL/SQL Errors
    -- Overview of PL/SQL Compile-Time Warnings

    2)
    wmsys.wm_concate

    你可以Sum() 数字列, 也可以 Sum() Varchar2 字符串列,
    我们叫作String Aggregate, 以后会有一长篇文章介绍.

    这里有一个示例, 自己在 SQL*Plus 或者SQL Developer里面跑一下吧,
    select DEFAULT_TABLESPACE,
    translate(wmsys.wm_concat(username),',','|')
    from dba_users
    group by DEFAULT_TABLESPACE;

    3)
    FBI index, virtual column index and SHRINK clause

    有个听众提个问题, 说在10.2以下版本, 有Function Based Index的表不能做空间回收-Shrink.
    Dan Morgan这位老大自己没测试过, 随口就说11g上,在一个表的虚拟列上的构建索引,这张表可以Shrink, 岂不是犯了和 老旦一样的错误.
    (老旦:Dan. 你们都知道是谁, 曾被老刘 Lewis 严肃的教育过, 以后有另外一篇文章评论,关于PGA 和 Parallel execution)

    第二天到办公室一测试, 发现11.1也不行.

    以下是测试用例:

    --drop table scott.y1;
    create table scott.y1(sal number, comm number);

    drop index scott.yi_fbi1;
    create index scott.yi_fbi1 on scott.y1(sal + comm)
    --tablespace data_auto
    ;

    alter table scott.y1 enable row movement;

    alter TABLE scott.y1 shrink space compact;
    alter TABLE scott.y1 shrink space;

    ERROR at line 1:
    ORA-10631: SHRINK clause should not be specified for this object

    drop index scott.yi_fbi1;

    alter table scott.y1 add (income AS (sal + comm));

    drop index scott.yi_vi1;
    create index scott.yi_vi1 on scott.y1(income);

    alter TABLE scott.y1 shrink space;

    ERROR at line 1:
    ORA-10631: SHRINK clause should not be specified for this object

    Sunday, February 03, 2008

    在加拿大给美国客户远程工作, 相关流程总结

    我自己亲身经历, 也有多位加拿大的华人朋友问到, 所以在这里总结一下.

    如果你是搞IT系统维护或开发的,这样的话VPN远程接入美国客户应该是通常的手段了.至于远程会议等要看对方要求了.一般公司都有WEBEX之类的.

    填一份 W-8BEN表格, 给美国客户寄去 备案, 就行了. 美国客户/雇主就可以开始给你付工钱了. (如果在美国工作, Independent Contractor 需要填w9 form)
    另外,对方有可能要求签一个安全保密协议, Non-Disclosure-Agreement.
    如果你觉得有必要, 再跟美国雇主签一个Offer(工作合同)

    美国公司如何支付工钱: 美国公司 "电子转帐或寄支票" 来 支付工钱

    纳税:
    1) 美国缴税 - 不用

    问过会计师了 无需向美国缴税
    刚刚打电话,问了会计师, 确认不用向美国缴税.
    下来就是明年报税, 找会计的问题了.

    加拿大居民/公民, 不用给美国缴税.
    If you perform the service from Canada, the income is not US source of income and is not taxable by US government.
    http://www.irs.gov/businesses/small/...=96459,00.html

    A nonresident alien (NRA) usually is subject to U.S. income tax only on U.S. source income.
    http://www.irs.gov/businesses/small/international/article/0,,id=96459,00.html

    Nonresident Aliensa
    A nonresident alien usually is subject to U.S. income tax only on U.S. source income.

    http://www.irs.gov/publications/p519/ch02.html#d0e1779

    <<
    如果你是美国公民, 绿卡持有人,

    根据w8 form 指南, 美国客户(Payor)会预先扣缴 30% 的税
    See: http://taxes.about.com/od/taxplanning/qt/form_W8BEN.htm
    >>

    2)加拿大缴税
    如果是 Independent Contractors, 交加拿大这边的30%~50%的个人所得税.

    注册公司:
    年收入在$30,000以下, 不需要在加拿大注册公司.
    (我个人觉得, 20万以下, 都不需要成立公司)
    注册个公司很容易,拿着公司注册号去开个银行帐号,然后就等对方电子转帐或寄支票了.
    http://www.smallbusinessbc.ca/bizResources-name.php
    http://www.bcbusinessregistry.ca/introduction/index.htm

    财务税务最好找个专业会计师.一年千把来块钱的开支,都可以打入公司运营成本, 还可以要回美国预扣的30%的税钱, 提交Form 8233.
    如果你恰好组织BC省府维多利亚市,我还可以给你介绍一个有这方面经验的华人专业会计师.

    也可以参考
    华枫论坛> ◆主题论坛◆> 创业者俱乐部.
    http://www.chinasmile.net/forums/showthread.php?t=303814

    下面是一些英文原文资料摘要:

    US Withholding for Canadian Independent Contractors

    Using Form W-8BEN to Claim US-Canada Tax Treaty Benefits
    American companies generally withhold income taxes on income being paid to foreign nationals. You may qualify for reduced withholding if meet some rules. Basically, there are three steps to this process. First, you must clarify in which country you are a resident. Second, you must decide where your "fixed place of business" is located. Third, you must notify your clients of your tax status using Form W-8BEN.
    Withholding
    The tax treaty specifically allows for US companies to withhold income taxes on self-employed Canadian residents (Article XVII, paragraph 1). Withholding will be 10% on the first $5,000 of income, and 30% on income over that threshold. The client and independent contractor may agree on a lesser percentage of withholding if these amounts are considered "excessive" (Article XVII, paragraph 2).
    Normally, US companies are required to "withhold 30% of any payment of an amount subject to withholding made to a payee that is a foreign person" (Instructions for Form W-8BEN). Form W-8BEN is used to inform the US company that you are "a beneficial owner that is a foreign person entitled to a reduced rate of withholding." You qualify for a reduced rate of withholding if you meet the residency and fixed place of business rules
    Filling out Form W-8BEN
    Provide your name in Line 1 and check "individual" in Line 3. However, if you are working under a business name, provide your business name in Line 1 and check the appropriate type of entity in Line 3.
    See: http://taxes.about.com/od/taxplanning/qt/form_W8BEN.htm

    Claiming Tax Treaty Benefits
    Exemption From Withholding
    If a tax treaty between the United States and your country provides an exemption from, or a reduced rate of, withholding for certain items of income, you should notify the payor of the income (the withholding agent) of your foreign status to claim the benefits of the treaty. Generally, you do this by filing Form W-8BEN, Certificate of Foreign Status of Beneficial Owner for United States Tax Withholding with the withholding agent.

    Rules that Apply to Compensation for Personal Services
    Independent contractors. If you perform personal services as an independent contractor (rather than an employee) and you can claim an exemption from withholding on that personal service income because of a tax treaty, submit Form 8233 to each withholding agent from whom amounts will be received.
    See: http://www.irs.gov/businesses/small/international/article/0,,id=96438,00.html


    Instructions for the Withholding Agent

    Requirement To Withhold
    A withholding agent must withhold 30% of any payment of an amount subject to withholding made to a payee that is a foreign person unless it can associate the payment with documentation (for example, Form W-8 or Form W-9) …
    Responsibilities of the Withholding Agent
    If you are a withholding agent making a payment of U.S. source interest, dividends, rents, royalties, commissions, nonemployee compensation, other fixed or determinable annual or periodical gains, profits, or income, and certain other amounts (including broker and barter exchange transactions, and certain payments made by fishing boat operators), you are generally required to obtain from the payee either a Form W-9, Request for Taxpayer Identification Number and Certification, or a Form W-8. These forms are also used to establish a person's status for purposes of domestic information reporting (for example, on a Form 1099) and backup withholding. If you receive a Form W-9, you must generally make an information return on a Form 1099. If you receive a Form W-8, you are exempt from reporting on Form 1099, but you may have to file Form 1042-S and withhold under the rules applicable to payments made to foreign persons. See the Instructions for Form 1042-S for more information.
    Generally, you must withhold 30% from the gross amount paid to a foreign person unless you can reliably associate the payment with a Form W-8. You can reliably associate a payment with a Form W-8 if you hold a valid form, you can reliably determine how much of the payment relates to the form, and you have no actual knowledge or reason to know that any of the information or certifications on the form are unreliable or incorrect.
    Do not send Forms W-8 to the IRS. Instead, keep the forms in your records for as long as they may be relevant to the determination of your tax liability under section 1461. Use the information on Forms W-8 to prepare Forms 1042-S.
    See: http://www.irs.gov/instructions/iw8/ch01.html