Total Pageviews

2014/12/17

How to Run Stored Procedure in Oracle SQL Developer

Problem
Assume I created a stored procedure which named PROC_FMS406R_TAB5_RPT1_STEP1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
create or replace PROCEDURE PROC_FMS406R_TAB5_RPT1_STEP1 
(
  INPUT_YYY_MM IN VARCHAR2 
, INPUT_LAST_YEAR IN VARCHAR2 
, INPUT_USER_ID IN VARCHAR2 
) AS 
BEGIN
  
  --1.5.2 計算『歲入估測分析表(含特別預算)』上一年度的一月到12月的實際數
 -- ignore execution detail

  
  
 --1.5.3 計算『歲入估測分析表(含特別預算)』上一年度的合計數
 -- ignore execution detail
  
END PROC_FMS406R_TAB5_RPT1_STEP1;


I tried to execute PROC_FMS406R_TAB5_RPT1_STEP1 in SQL worksheet


It will fail to execute and show this error message:

1
2
3
4
命令的第 2 行開始發生錯誤 -
PROC_FMS406R_TAB5_RPT1_STEP1(:INPUT_YYY_MM, :INPUT_LAST_YEAR, :INPUT_USER_ID)
錯誤報告 -
不明的命令

How to Fix This Problem
Add BEGIN before the stored procedure and add END; after the stored procedure.

1
2
3
BEGIN
PROC_FMS406R_TAB5_RPT1_STEP1(:INPUT_YYY_MM, :INPUT_LAST_YEAR, :INPUT_USER_ID);
END;


Reference
[1] http://dba.stackexchange.com/questions/57163/how-to-run-procedure-in-oracle-sql-developer

2014/12/16

Utilize Styles to Change Font Color Based on Condition in iReport

Problem
Customer ask us to change font color to red if the amount is less than zero.

It should look like this:


Solution
  • Step1. Move cursor to "Styles" and right click => Add => Style


  • Step2. Right click on "style1" => Add "Conditional Style"


  • Step3. Edit "Conditional Expression" ( apply this style if $F(amount) value is less than zero)


  • Step4. Set font color to RED


  • Step5. Owning to set font color to red, it will set line color to red as well. Hence, we need to set line color to black manually.


  • Step6. Click on $F{amount} and set "Style" to "style1" which we create and configure in Step2 ~ Step5.



2014/12/15

How to revert changes in EGit

Assume I have a form bean in gov.nta.dbm.web.dto

The form bean is as following:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
package gov.nta.dbm.web.dto;

import java.io.Serializable;

import org.apache.commons.lang.builder.ToStringBuilder;

import lombok.Data;

@Data
public class Dbm915rFormBean implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private int year = 0;
    private int month = 0;
    
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}

If I add one more attribute in this form bean:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package gov.nta.dbm.web.dto;

import java.io.Serializable;

import org.apache.commons.lang.builder.ToStringBuilder;

import lombok.Data;

@Data
public class Dbm915rFormBean implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private int year = 0;
    private int month = 0;
    private String type;
    
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}

We can see this form bean had been modified and add ">" icon before file name to remind us this file had been modified.

If I would like to revert its changes, just right click => Replace with => HEAD Revision

Click OK to make sure to discard changes.

We can see the ">" label is disappeared.

And the form bean had been revert to original version:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
package gov.nta.dbm.web.dto;

import java.io.Serializable;

import org.apache.commons.lang.builder.ToStringBuilder;

import lombok.Data;

@Data
public class Dbm915rFormBean implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private int year = 0;
    private int month = 0;
    
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}


If you find out your revert action is success, but the ">" label still show in Eclipse.
Its EGit bug, go to its website ( http://eclipse.org/egit/download/ ) to update your EGit version.

2014/12/11

Checkout remote Git branch

Owing to our software development had been outsourced, here is the delivery process as function completion: 



As outsourced programmer completed his/her own function, he/she need to go to Gitlab to create a merge request to remind us:



Then we need to checkout his/her branch which he/she pushed to do code review.


Assume our initial branch is master, then there is the process to check out remote Git branch:



  • 1. Team => Remote => Fetch From...


  • 2. Click "Next"
  • 3. You can find out the branch name in merge request no matter in Gitlab or email. Hence, configure the source and destination ref. And click "Finish" button.

  •  4. Click OK


  • 5. Team => Switch To => Other..


  • 6. Remote Tracking => select specific branch name => Checkout.


  • 7. Checkout


  • 8. Click "Finish"


  • 9. We had changed from master to "DBM915R_new_function"







2014/12/09

Utilize CLOC(Count Lines of Code) to count lines of code

Requirement
If I would like to count lines of code for each Java program in my Java project, which tool can help me?

Solution
Go to http://cloc.sourceforge.net/ to download exe file (i.e. cloc-1.62.exe).

Assume cloc-1.62.exe had been saved into D:\software
Assume the Java project located in D:\workspace2\ave\ave-webapp\src\main\java
  • Step1. open command prompt.
  • Step2. Change directory to Java project directory, i.e. D:\workspace2\ave\ave-webapp\src\main\java
  • Step3. Execute this command: d:\software\cloc-1.62.exe . --by-file

Check the result:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
D:\workspace2\ave\ave-webapp\src\main\java>d:\software\cloc-1.62.exe . --by-file
      94 text files.
      94 unique files.
       8 files ignored.

http://cloc.sourceforge.net v 1.62  T=0.32 s (296.3 files/s, 60038.9 lines/s)
------------------------------------------------------------------------------------------------------------
File                                                                     blank        comment           code
------------------------------------------------------------------------------------------------------------
.\gov\nta\ave\web\rest\Ave102eResource.java                                369            299           1505
.\gov\nta\ave\web\rest\Ave104eResource.java                                195            235            907
.\gov\nta\ave\web\rest\Ave103eResource.java                                198            235            891
.\gov\nta\ave\web\rest\Ave101eResource.java                                199            242            890
.\gov\nta\ave\web\rest\Ave106eResource.java                                188            148            783
.\gov\nta\ave\web\rest\Ave401eResource.java                                212            234            772
.\gov\nta\ave\web\rest\Ave201eResource.java                                110             91            576
.\gov\nta\ave\web\rest\Ave105eResource.java                                 85             16            405
.\gov\nta\ave\web\controller\Ave608rReportController.java                  107            114            338
.\gov\nta\ave\web\controller\Ave201eReportController.java                   69             38            334
.\gov\nta\ave\web\rest\Ave904eResource.java                                 57             71            309
.\gov\nta\ave\web\rest\Ave903eResource.java                                 80             23            251
.\gov\nta\ave\web\controller\Ave114rReportController.java                   58             43            227
.\gov\nta\ave\web\controller\Ave613rReportController.java                   54             37            194
.\gov\nta\ave\web\controller\Ave401eReportController.java                   70             38            178
.\gov\nta\ave\web\rest\Ave121eResource.java                                 46             26            168
.\gov\nta\ave\web\rest\Ave115qResource.java                                 31             38            168
.\gov\nta\ave\web\rest\Ave907eResource.java                                 45             66            157
.\gov\nta\ave\web\rest\Ave117rResource.java                                 50             43            150
.\gov\nta\ave\web\controller\Ave609rReportController.java                   33             35            148
.\gov\nta\ave\web\controller\Ave108rReportController.java                   35             41            147
.\gov\nta\ave\web\controller\Ave116rReportController.java                   43             24            146
.\gov\nta\ave\web\rest\Ave909eResource.java                                 39             13            140
.\gov\nta\ave\web\controller\Ave611rReportController.java                   30             12            137
.\gov\nta\ave\web\controller\Ave502rReportController.java                   40             30            117
.\gov\nta\ave\web\controller\Ave105eReportController.java                   24              2            112
.\gov\nta\ave\web\controller\Ave610rReportController.java                   40             29            111
.\gov\nta\ave\web\rest\Ave905eResource.java                                 31              4            108
.\gov\nta\ave\web\controller\Ave605rReportController.java                   24             16            104
.\gov\nta\ave\web\rest\Ave112qResource.java                                 32             25            100
.\gov\nta\ave\web\controller\Ave117rReportController.java                   17             11             82
.\gov\nta\ave\web\rest\Ave501eResource.java                                 14              0             78
.\gov\nta\ave\web\controller\Ave607rReportController.java                   20             10             75
.\gov\nta\ave\web\dto\Ave102eFormBean.java                                  40             32             75
.\gov\nta\ave\web\rest\Ave114rResource.java                                 16             25             73
.\gov\nta\ave\web\controller\Ave601rReportController.java                   17              2             71
.\gov\nta\ave\web\rest\Ave901eResource.java                                 15              0             71
.\gov\nta\ave\web\controller\Ave602rReportController.java                   17              2             71
.\gov\nta\ave\web\rest\Ave110qResource.java                                 19              1             70
.\gov\nta\ave\web\dto\Ave106eFormBean.java                                  26             16             68
.\gov\nta\ave\web\controller\Ave405rReportController.java                   18             10             67
.\gov\nta\ave\web\rest\Ave122qResource.java                                 14              8             67
.\gov\nta\ave\web\controller\Ave406rReportController.java                   23              4             67
.\gov\nta\ave\web\rest\Ave111qResource.java                                 17              1             64
.\gov\nta\ave\web\controller\Ave612rReportController.java                   17             11             61
.\gov\nta\ave\web\controller\Ave604rReportController.java                   16              1             58
.\gov\nta\ave\web\controller\Ave403rReportController.java                   18             12             56
.\gov\nta\ave\web\dto\Ave101eFormBean.java                                  14              7             56
.\gov\nta\ave\web\dto\Ave103eFormBean.java                                  14              7             56
.\gov\nta\ave\web\dto\Ave104eFormBean.java                                  14              7             56
.\gov\nta\ave\web\controller\Ave408rReportController.java                   18             11             55
.\gov\nta\ave\web\controller\Ave603rReportController.java                   14              0             53
.\gov\nta\ave\web\controller\Ave410rReportController.java                   15             21             53
.\gov\nta\ave\web\controller\Ave606rReportController.java                   16             10             52
.\gov\nta\ave\web\controller\Ave115qReportController.java                   14              9             46
.\gov\nta\ave\web\controller\Ave107rReportController.java                   12              5             46
.\gov\nta\ave\web\controller\Ave904eReportController.java                   14              1             45
.\gov\nta\ave\web\rest\Ave902eResource.java                                 10              0             45
.\gov\nta\ave\web\controller\Ave113qReportController.java                   11              6             44
.\gov\nta\ave\web\dto\Ave201eFormBean.java                                  19             12             43
.\gov\nta\ave\web\controller\Ave203rReportController.java                   16             16             43
.\gov\nta\ave\web\controller\Ave501eReportController.java                   11              0             42
.\gov\nta\ave\web\controller\Ave903eReportController.java                   13              1             41
.\gov\nta\ave\web\controller\Ave901eReportController.java                   14              0             36
.\gov\nta\ave\web\controller\Ave402rReportController.java                   11              0             36
.\gov\nta\ave\web\controller\Ave303rReportController.java                   10              0             35
.\gov\nta\ave\web\controller\Ave302rReportController.java                   11              2             33
.\gov\nta\ave\web\rest\Ave113qResource.java                                  8             14             32
.\gov\nta\ave\web\controller\Ave404rReportController.java                    8              7             31
.\gov\nta\ave\web\controller\Ave204rReportController.java                    9              7             30
.\gov\nta\ave\web\controller\Ave202rReportController.java                    6              0             30
.\gov\nta\ave\web\controller\Ave407rReportController.java                    8              1             28
.\gov\nta\ave\web\controller\Ave301rReportController.java                    9              1             28
.\gov\nta\ave\web\controller\Ave409rReportController.java                    9              1             28
.\gov\nta\ave\web\dto\Ave608rFormBean.java                                  21              0             24
.\gov\nta\ave\web\dto\Ave609rFormBean.java                                  19              0             22
.\gov\nta\ave\web\dto\Ave401eFormBean.java                                  19              0             22
.\gov\nta\ave\web\dto\Ave903eFormBean.java                                  16              0             19
.\gov\nta\ave\web\dto\Ave121eFormBean.java                                  14              0             18
.\gov\nta\ave\web\dto\Ave613rFormBean.java                                   7              0             18
.\gov\nta\ave\web\dto\Ave610rFormBean.java                                  10              0             13
.\gov\nta\ave\web\dto\Ave105eFormBean.java                                   7              0             11
.\gov\nta\ave\web\dto\Ave122qFormBean.java                                   6              0             10
.\gov\nta\ave\web\dto\Ave907eFormBean.java                                   4              0              8
.\gov\nta\ave\web\dto\Ave113qFormBean.java                                   4              0              7
.\gov\nta\ave\web\dto\Ave905eFormBean.java                                   2              0              7
.\gov\nta\ave\web\dto\Ave203rFormBean.java                                   2              0              7
.\gov\nta\ave\web\dto\ComboboxDto.java                                       4              0              7
.\gov\nta\ave\web\dto\Ave606rFormBean.java                                   2              0              7
.\gov\nta\ave\web\dto\Ave404rFormBean.java                                   2              0              7
.\gov\nta\ave\web\dto\Ave403rFormBean.java                                   3              0              6
.\gov\nta\ave\web\rest\package-info.java                                     0              5              1
.\gov\nta\ave\web\controller\package-info.java                               0              3              1
.\gov\nta\ave\web\dto\package-info.java                                      0              3              1
------------------------------------------------------------------------------------------------------------
SUM:                                                                      3388           2571          13086
------------------------------------------------------------------------------------------------------------

D:\workspace2\ave\ave-webapp\src\main\java>


Reference
[1] http://cloc.sourceforge.net/

How to mock autowired fields via Mockito

Problem
Assume we wrote a calculation service which provide add and subtract service.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Service;

/**
 * The Class CalculationService.
 */
@Service
@Slf4j
public class CalculationService {

    public int add(int num1, int num2) {
        return num1 + num2;
    }
    
    public int subtract(int num1, int num2) {
        return num1 - num2;
    }
    
}

If we would like to do unit test for CalculationService class, and autowire CalculationService into service class as bellows:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import static org.junit.Assert.assertEquals;
import gov.nta.nss.service.CalculationService;

import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

public class CalculationServiceTest {

    /* Inject CalculationService */
    @Autowired
    private CalculationService service;

    /* Test add function in CalculationService */
    @Test
    public void testAdd() {
        // arrange & act
        int result = service.add(6, 5);

        // assert
        assertEquals(11, result);
    }

    /* Test subtract function in CalculationService */
    @Test
    public void testSubtract() {
        // arrange & act
        int result = service.subtract(6, 5);

        // assert
        assertEquals(1, result);
    }

}

As I executed this test class, it returned NullPointerException. This exception result from failed to autowire CalculationService. How to overcome this problem?



Solution
We can mock autowired fields by Mockito to solve this problem. Here is the revised test code:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import static org.junit.Assert.assertEquals;
import gov.nta.nss.service.CalculationService;

import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;

public class CalculationServiceTest {

    /* Inject CalculationService */
    @InjectMocks
    private CalculationService service;

    /* Initialized mocks */
    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
    }

    /* Test add function in CalculationService */
    @Test
    public void testAdd() {
        // arrange & act
        int result = service.add(6, 5);

        // assert
        assertEquals(11, result);
    }

    /* Test subtract function in CalculationService */
    @Test
    public void testSubtract() {
        // arrange & act
        int result = service.subtract(6, 5);

        // assert
        assertEquals(1, result);
    }

}

Test result is bellowing:


Reference
[1] http://lkrnac.net/blog/2014/01/mock-autowired-fields/
[2] http://docs.mockito.googlecode.com/hg/org/mockito/Mockito.html


2014/12/05

How to implement indexOf in Oracle

Requirement
In Java, we can use indexOf method if we would like to return the index within this string of the first occurrence of the specified character. For instance, if we would like to get the characters which before left parenthesis, we can do this way. 

1
2
3
4
5
6
    public static void main(String[] args) {
        String str1 = "ABC(12345)";
        String str2 = "BC(34567)";
        System.out.println(str1.substring(0, str1.indexOf("(")));
        System.out.println(str2.substring(0, str2.indexOf("(")));
    }

But Oracle does not provide OOTB(Out of The Box) function to fulfill this requirement.

How to do 
We can make good use of INSTR function, the syntax is:

The INSTR functions search string for substring. The function returns an integer indicating the position of the character in string that is the first character of this occurrence. INSTR calculates strings using characters as defined by the input character set. INSTRB uses bytes instead of characters. INSTRC uses Unicode complete characters. INSTR2 uses UCS2 code points. INSTR4 uses UCS4 code points.

  • position is an nonzero integer indicating the character of string where Oracle Database begins the search. If position is negative, then Oracle counts backward from the end of string and then searches backward from the resulting position.
  • occurrence is an integer indicating which occurrence of string Oracle should search for. The value of occurrence must be positive.

Here has an example to fulfill this requirement:
1
2
SELECT SUBSTR('ABC(12345)', 0, INSTR('ABC(12345)', '(', 1, 1)-1) FROM DUAL;
SELECT SUBSTR('BC(34567)', 0, INSTR('BC(34567)', '(', 1, 1)-1 ) FROM DUAL;


Reference
[1] https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions068.htm#i77598
[2] http://fanli7.net/a/shujuku/Oracle/20120615/171956.html

2014/12/01

[閱讀筆記] 史丹佛給你讀得懂的經濟學

  1. 所得不均的問題在於流動性,處於所得分配最底層的人會往上升一點,但很少能持續移動到最上層。同樣的,處於所得分配最頂層的人可能會往後退,但很少一直退到最底層
  2. 社會救助的兩難,他應該像高空盪韆表演者下方的安全網,緩衝你掉落的力道,也幫助妳再彈上去。但常常因為社會救助產生就業鎖,因為就業獲得收入卻因此失去社會救助,產生負所得稅問題
  3. 總體經濟政策的四個目標是:經濟成長、低失業率、低通貨膨脹率、可支應成長的貿易餘額
  4. GDP(國內生產毛額)的定義是:計算一個經濟體一年內所生產的最終產品和服務的總價值,GDP可以根據產銷的商品價值,或需求與購買的商品價值來衡量。GDP = 消費 + 投資 + 政府支出 + 出口 - 進口
  5. 所得最低的國家,並不是因為全球化才變窮,而是因為和全世界其他地區脫節才變更窮
  6. 生產力成長的三大驅動因子是:實體資本增加(更多個資本設備讓員工使用)、更多的人力資本(員工有更多的經驗或教育)以及更好個技術(更有效率的生產方式)
  7. 工資提昇的基礎在於增加員工的平均生產力(及更好的教育投資)、更好的實體資本設備投資,以及發明並採用新技術。當一個國家可以把這三個因素結合在一起,就能達成工作好且薪資佳的理想目標
  8. 政府預算赤字上升,以下三件事的某些組合必然會發生:私人儲蓄上升、私人投資下降、外資流入增加
  9. 如果政府借越來越多錢來管理他的赤字,就會降低民間企業可取得用於投資的資金。因此政府借款增加意味著私人投資減少,相反的,政府借款減少表示企業可以取得更多資金用於投資
  10. 新廠房與新設備的實體資本投資,是經濟成長的基本元素之一,也是把新技術導入生產流程的關鍵方式之一。如果政府使預算赤字降低,企業可以取得更多資金,更容易採用新技術,有助於長期經濟成長。若預算赤字偏高,就會排擠私人投資,影響未來經濟成長
  11. 經濟學家把社會上具備以下三個功能的任何物品定義為貨幣:交易媒介、價值儲存、計價單位。房屋可以作為價值儲存,可以累積價值且可以賣掉他;但是房屋不能作為交易媒介,你不能買一台車時付給業務員一間臥室;房屋無法作為計價單位,你不知道一磅雞肉值多少浴室
  12. 銀行拼命放款時,由於這些放款造成購買力增加,社會將出現大量的總和需求。反之,若經濟不景氣,銀行可能決定減少貸款,避免錢收不回來。此時,社會的購買力和總和需求會減少。如果放款金額減少,就會對整個社會的經濟活動造成影響
  13. 中央銀行有三個傳統工具,可以在銀行與貨幣的架構內運作:法定準備金(reserve requirement)、重貼現率(discount rate)、公開市場操作(open market operation)
  14. 法定準備金,是銀行不可放貸出去的存款比例。當法定準備率提高時,銀行可以貸出的貨幣就變少,民間可獲得的貸款減少,總和需求就會縮小,市場利率提昇,借款變得較不吸引人;相反的,若法定準備金下降,市場利率就會下降,借款代價就會降低
  15. 重貼現率,是央行可以助長或抑制放款的另一種方式。如果中央銀行提高重貼現率,就會股利銀行手頭持有貨幣,銀行就會少貸出一些錢,降低了市場上的貨幣數量。相反的,如果降低重貼現率,銀行就會多貸出一些錢,增加市場上的貨幣供給
  16. 公開市場操作,是指中央銀行購買或銷售債券,藉以增加或減少貨幣供給。當聯準會購買債券,銀行就會擁有現金,而且可以增加他的放款金額,總和需求隨之上升。如果連準備賣債券給銀行,就會減少銀行今,銀行放款變少,民間流通的貨幣變少,總和需求就會下降
  17. 公開市場操作是近幾十年來,美國最常用的貨幣政策,主要的理由是,改變法定準備率與重貼現率,需要預測銀行如何因應這些規則變化,這是一個不確定的過程。但是透過公開市場操作,連準備決定買賣特定數量的債券,變能對市場利率變化來看結果,然後決定買賣更多或更少的債券
  18. 聯準會如果想讓貨幣供給變大,他有四個選擇;降低法定準備率、降低重貼現率、向銀行購買債券,或是購買與借款有關的證券。這些措施都可以稱為擴張性(或寬鬆)的貨幣政策
  19. 擴張性或寬鬆的貨幣政策,不會降低自然失業率。自然失業率,取決於動態市場裡勞動的供給與需求,會受到工作及雇用的誘因影響,如影響員工行為的福利與失業津貼,以及影響雇用成本與員工行為的規章制度
  20. 當通膨率出現負數時,稱作通貨緊縮(deflation),意即貨幣的購買力沒有隨著時間變低,反而隨著時間變得更有價值。聽起來不是一件壞事,但是當通貨緊縮與利率相互作用時,會造成貨幣政策難以處理的經濟衰退
  21. 實質利率=名目利率-通膨率,如果名目利率是7%,通膨率是-2%(通貨緊縮),實質利率變成9%,此時借款人的實質利率變高,導致銀行大量放款變成呆帳,銀行會變得無意承做新貸款,導致總體經濟需求下降,導致經濟衰退
  22. 當價格上升不是出於商品本身的任何特色,而是因為投資人期望價格持續上升時,稱之為泡沫。泡沫會創造其自身的動能,因為很多人突然購買,往往會推升價格,當足夠茤的人認清泡沫無法維持的時候,價格就會暴跌
  23. 貨幣政策像拉或推一條繩子,拉繩子時,他會向你移動,但你推繩子時,它會彎折起來而繩尾不動如山。當中因銀行透過收縮性政策拉繩子時,它可以明確地提高利率並降低總和需求;但若試圖透過擴張性政策推繩子,只要銀行仍決定不放款,那麼貨幣政策不會有任何效果
  24. 相似商品跨國界的貿易,會對國內生產者造成更大的競爭,然而競爭並非壞事,競爭有助於低價與創新
  25. 保護主義是政府對國內產業提供間接補貼,但國內消費者卻要用較高的價格買單
  26. 國際貿易的開放與閉鎖,與整體就業水準無關。循環性失業與經濟榮枯有關,自然失業率則與勞動市場誘因有關。保護主義不會讓就業機會變多,自由貿易也不會使就業機會減少
  27. 窮國與富國的差距越來越大,是因為窮國缺乏貿易,沒有參與全球化。例如日本、南韓、中國以及印度,都是運用對外貿易作為主要成長引擎之一
  28. 強勢貨幣有助於外國資金的淨流入,弱勢貨幣則會抑制資金流入。換句話說,強勢美元有助於外國人投資美國資產,而不是購買美國商品。反之,弱勢美元有助於外國人購買美國製的出口品,而不是投資美國資產
  29. 遭遇金融危機的國家都有某些共同點:國家GDP會大幅萎縮。如墨西哥在1995年萎縮6%、印尼在1998年萎縮13%、阿根廷在2002年萎縮11%
  30. 外資分成兩類:一是購買有形的公司或工廠的直接投資,二是購買股票或債券等金融工具的證券投資。直接投資比較不可能迅速撤出,因為一時衝動賣掉工廠是有難度的,而且直接投資者比較偏向長期收益。故如果中小型國家打算管制外資,鼓勵直接投資是可能的最佳方法


2014/11/30

2014/11 Travel

石門水庫

光之穹頂 Dome of Light

駁二藝術特區


E-DA ROYAL HOTEL