andykeung1617 2017-2-21 19:28
[b]我是個寫程式新手,有個小小的問題想請教下?[/b] [b]以下[/b][b]package [/b][b]寫法是否有問題?墾請解答[/b][b]Thanks [/b]🙇🏻
[b]FUNCTION get_period[/b][b]([/b][b]p_fill_in_date_fr IN VARCHAR2[/b][b],[/b][b] p_fill_in_date_to IN VARCHAR2[/b][b],[/b][b] p_adjust_date_fr IN VARCHAR2[/b][b],[/b][b] p_adjust_date_to IN VARCHAR2[/b][b])[/b]
[b]RETURN NUMBER[/b]
[b]IS[/b]
[b]n_get_period_return NUMBER[/b][b];[/b]
[b]n_c1 NUMBER;[/b]
[b]n_c2 NUMBER;[/b]
[b]BEGIN[/b]
[b]SELECT Count[/b][b]([/b][b]*[/b][b])[/b]
[b]INTO n_c1[/b]
[b]FROM apps.abc_order_receipt_adj a[/b][b],[/b]
[b]apps.abc_order_receipt r[/b]
[b]WHERE a.order_receipt_no = r.order_receipt_no[/b]
[b]AND trunc[/b][b]([/b][b]r.fill_in_date[/b][b])[/b][b] = to_date[/b][b]([/b][b]p_fill_in_date_fr[/b][b],[/b][b] 'DD-MON-YYYY'[/b][b])[/b]
[b]AND trunc[/b][b]([/b][b]r.fill_in_date[/b][b])[/b][b] = to_date[/b][b]([/b][b]p_fill_in_date_to[/b][b],[/b][b] 'DD-MON-YYYY'[/b][b])[/b]
[b]SELECT Count[/b][b]([/b][b]*[/b][b])[/b]
[b]INTO n_c2[/b]
[b]FROM apps.abc_order_receipt_adj a[/b][b],[/b]
[b]apps.abc_order_receipt r[/b]
[b]WHERE a.order_receipt_no = r.order_receipt_no[/b]
[b]AND trunc[/b][b]([/b][b]a.adj_date[/b][b])[/b][b] = to_date[/b][b]([/b][b]p_adjust_date_fr[/b][b],[/b][b] 'DD-MON-YYYY'[/b][b])[/b]
[b]AND trunc[/b][b]([/b][b]a.adj_date[/b][b])[/b][b] = to_date[/b][b]([/b][b]p_adjust_date_to[/b][b],[/b][b] 'DD-MON-YYYY'[/b][b])[/b]
[b]IF [/b][b]([/b][b]n_c1 > 0 AND n_c2 > 0 [/b][b])[/b][b] THEN[/b]
[b]RETURN TRUE[/b][b];[/b]
[b]END IF[/b][b];[/b]
[b]RETURN n_get_period_return[/b][b];[/b]
[[i] 本帖最後由 andykeung1617 於 2017-2-22 07:38 AM [url=http://www.discuss.com.hk/iphone][img=100,23]http://i.discuss.com.hk/d/images/r10/iphoneD.jpg [/img][/url] 編輯 [/i]]
andykeung1617 2017-2-22 08:06
[quote]原帖由 [i]McLoneV[/i] 於 2017-2-22 07:24 AM 發表 [url=http://www.discuss.com.hk/redirect.php?goto=findpost&pid=456810432&ptid=26463015][img]http://www.discuss.com.hk/images/common/back.gif[/img][/url]
有什麼error? [/quote]
[b]CREATE OR REPLACE PACKAGE abc_or IS[/b]
[b]FUNCTION get_period (p_fill_in_date_fr IN VARCHAR2, p_fill_in_date_to IN VARCHAR2, p_adjust_date_fr IN VARCHAR2,[/b]
[b]p_adjust_date_to IN VARCHAR2) RETURN number; [/b]
[b]END abc_or;[/b]
[b]/ [/b]
[b]CREATE OR REPLACE PACKAGE BODY abc_or IS[/b]
[b]FUNCTION get_period(p_fill_in_date_fr IN VARCHAR2, [/b]
[b]p_fill_in_date_to IN VARCHAR2, [/b]
[b]p_adjust_date_fr IN VARCHAR2, [/b]
[b]p_adjust_date_to IN VARCHAR2) [/b]
[b]RETURN NUMBER[/b]
[b]IS[/b]
[b]n_get_period_return NUMBER;[/b]
[b]n_c1 NUMBER;[/b]
[b]n_c2 NUMBER;[/b]
[b]BEGIN[/b]
[b]SELECT Count(*)[/b]
[b]INTO n_c1[/b]
[b]FROM cbc.abc_order_receipt_adj a, [/b]
[b]cbc.abc_order_receipt r[/b]
[b]WHERE a.order_receipt_no = r.order_receipt_no[/b]
[b]AND trunc(r.fill_in_date) = to_date(p_fill_in_date_fr, 'DD-MON-YYYY')[/b]
[b]AND trunc(r.fill_in_date) = to_date(p_fill_in_date_to, 'DD-MON-YYYY');[/b]
[b]SELECT Count(*)[/b]
[b]INTO n_c2[/b]
[b]FROM cbc.abc_order_receipt_adj a, [/b]
[b]cbc.abc_order_receipt r[/b]
[b]WHERE a.order_receipt_no = r.order_receipt_no[/b]
[b]AND trunc(a.adj_date) = to_date(p_adjust_date_fr, 'DD-MON-YYYY')[/b]
[b]AND trunc(a.adj_date) = to_date(p_adjust_date_to, 'DD-MON-YYYY') ;[/b]
[b]IF (n_c1 > 0 AND n_c2 > 0 ) THEN[/b]
[b]RETURN n_c1;[/b]
[b]RETURN n_c2;[/b]
[b]END IF;[/b]
[b]RETURN n_get_period_return;[/b]
[b]PLS-00323: subprogram or cursor 'GET_PERIOD' is declared in a package specification and must be defined in the package body[/b]
[b]暫時未知有關錯誤原因[/b][b].....[/b]
[[i] 本帖最後由 andykeung1617 於 2017-2-22 11:01 AM [url=http://www.discuss.com.hk/iphone][img=100,23]http://i.discuss.com.hk/d/images/r10/iphoneD.jpg [/img][/url] 編輯 [/i]]