从 oracle 表单调用 excel 函数

发布于 2024-09-25 11:07:51 字数 64 浏览 4 评论 0原文

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

Can anyone suggest how I can use ole2 to perform an excel function (e.g. PMT()), from oracle forms and get back the result??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

日记撕了你也走了 2024-10-02 11:07:51

我创建了 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;

I created PL/SQL functions that will calculate the PMT function per the formula that is in MS Excel.

This first function doesn't factor in the future value, the second does.

/* 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;
相思碎 2024-10-02 11:07:51

我只需在 PL/SQL(表单的本机语言)中重新创建 PMT 函数。例如基于 http:// forums.contractoruk.com/technical/28716-calculate-apr-loan-re payment-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;

例如

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

PMT = $513.07

I would just recreate the PMT function in PL/SQL, the native language of forms. E.g. based on 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文