⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 custrules.pkg

📁 OReilly Oracle PL SQL Programming第4版源代码
💻 PKG
字号:
CREATE OR REPLACE PACKAGE customer_rules
IS
    FUNCTION min_balance RETURN PLS_INTEGER;  /* Toronto */
    
    FUNCTION eligible_for_discount 
       (customer_in IN customer%ROWTYPE) 
       RETURN BOOLEAN;

    FUNCTION eligible_for_discount 
       (customer_id_in IN customer.customer_id%TYPE) 
       RETURN BOOLEAN;

END customer_rules;
/
CREATE OR REPLACE PACKAGE BODY customer_rules
IS
    c_min_balance CONSTANT PLS_INTEGER := 10000;
       
    FUNCTION min_balance RETURN PLS_INTEGER 
       IS BEGIN RETURN c_min_balance; END;  /* TORONTO */
    
    FUNCTION eligible_for_discount 
       (customer_in IN customer%ROWTYPE) 
       RETURN BOOLEAN
    IS
	    retval BOOLEAN;
    BEGIN
	     /* Perform all validations here. */
		  retval := 
		     customer_in.balance > min_balance AND
		     customer_in.pref_type = 'MOST FAVORED' AND 
             customer_in.disc_eligibility;

        RETURN retval;
    END;

    FUNCTION eligible_for_discount 
       (customer_id_in IN customer.customer_id%TYPE) 
       RETURN BOOLEAN
    IS
	    customer_rec customer%ROWTYPE;
    BEGIN
        /* Retrieve a record for this primary key. */
		  customer_rec := te_customer.onerow (customer_id_in);

        /* Use other function to calculate eligibility. */
		  RETURN eligible_for_discount (customer_rec);
    END;
END customer_rules;
/



/*======================================================================
| Supplement to the third edition of Oracle PL/SQL Programming by Steven
| Feuerstein with Bill Pribyl, Copyright (c) 1997-2002 O'Reilly &
| Associates, Inc. To submit corrections or find more code samples visit
| http://www.oreilly.com/catalog/oraclep3/
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -