从oracle表单调用excel函数

时间:2010-09-28 21:27:33

标签: oracle excel oracleforms

任何人都可以建议我如何使用ole2来执行excel函数(例如PMT()),从oracle表单中取回结果?

2 个答案:

答案 0 :(得分:0)

我只想在PL / SQL中重新创建PMT函数,PL / SQL是表单的本地语言。例如。基于http://forums.contractoruk.com/technical/28716-calculate-apr-loan-repayment-using-pl-sql-java.html

CREATE
FUNCTION pmt (rate     IN NUMBER /* Rate (APR) */
             ,amt      IN NUMBER /* Loan amount */
             ,payments IN NUMBER /* number of payments */
             ) RETURN NUMBER IS /* periodic payment amount */
BEGIN
  RETURN (rate/12*amt*power((1+rate/12),payments))/(power((1+rate/12),payments)-1);
END pmt;

e.g。

BEGIN
  DBMS_OUTPUT.put_line(
   'PMT = $' || TRUNC( pmt(0.249, 5000, 11), 2)
  );
END;
/

PMT = $513.07

答案 1 :(得分:0)

我创建了PL / SQL函数,它们将根据MS Excel中的公式计算PMT函数。

第一个函数不会影响未来的值,第二个函数不会。

/* No future value factor */
FUNCTION pmt (APR     IN NUMBER /* Rate (APR) */,
                  pv      IN NUMBER /* Loan amount */,
                  nper    IN NUMBER /* number of payments */
                  ) RETURN NUMBER IS /* periodic payment amount */
BEGIN
    RETURN  (APR / (1 - power((1 + APR),-nper)) * pv );

END pmt;    

/* With future value factor */
FUNCTION pmt (APR    IN NUMBER, /* Rate (APR) */
              nper   IN NUMBER, /* Number of payments */
              pv     IN NUMBER, /* present value */
              fv     IN NUMBER  /*future value */
             ) RETURN NUMBER IS /* periodic payment amount */

  calcpmt NUMBER := 0;
  powercalc NUMBER:=0;
BEGIN

 powercalc:= POWER(1+APR, nper);
 RETURN APR / (powercalc - 1) * -(pv * powercalc + fv);

END;