在oracle表单中从from子句查询填充数据块

kd3sttzy  于 2023-04-11  发布在  Oracle
关注(0)|答案(2)|浏览(174)

我正在尝试像这样填充数据块:

PROCEDURE POP_BLOCK IS
    Q VARCHAR2(2000);
BEGIN
    Q:='(SELECT ROW_NUMBER () OVER (ORDER BY ROWNUM) SR, LN_DT, PER_MNTH, DEP_CR,
         FIRST_VALUE (LOAN_AMOUNT - DOWN_PAYMENT) OVER (ORDER BY ROWNUM)
       - SUM (PER_MNTH + DEP_CR) OVER (ORDER BY ROWNUM) BALANCE
  FROM (SELECT CAR_LOAN.REGCODE, ROW_NUMBER () OVER (ORDER BY ROWNUM) SR,
               LN_DT, PER_MNTH, CASE
                  WHEN ROWNUM >= 49
                     THEN 0
                  ELSE DEP_CR
               END DEP_CR, LOAN_AMOUNT, DOWN_PAYMENT
          FROM CAR_LOAN, TABLE (LOANINST (CAR_LOAN.LOAN_DATE)))
  )  WHERE REGCODE = '
    ||:LOAN_SYSTEM.REGCODE||')';
    GO_BLOCK('CAR_LOAN_INSTALLMENT');
   Clear_Block ;
SET_BLOCK_PROPERTY('CAR_LOAN_INSTALLMENT', QUERY_DATA_SOURCE_NAME,Q); 
EXECUTE_QUERY;
EXCEPTION WHEN OTHERS THEN
    MESSAGE(SQLCODE || SQLERRM);
    MESSAGE(SQLCODE || SQLERRM);
END;

我在新的表单示例上调用这个过程,当我运行表单时,它给出一个错误:
frm-41380 error - cannot set the blocks query data source
谁能告诉我这里的问题是什么,我现在应该做什么?

deyfvvtc

deyfvvtc1#

我也有类似的问题。请确保CAR_LOAN_INSTALLMENT数据块具有以下属性(这有助于我解决问题):
数据库数据块:是的
允许查询:是的
查询数据源类型:FROM子句查询
查询数据源名称:输入表/视图名称或SELECT查询
假设REGCODE是一个数字,而不是VARCHAR 2。如果是后者,请确保在动态查询中将其括在单引号中(即上面的Q)。
致上,
吉里什

pnwntuvh

pnwntuvh2#

Block Name : CAR_LOAN_INSTALLMENT
Set the properties for this block as follows:

1. Database Data Block: Yes
   Query Allowed: Yes
   Query Data Source Type: FROM clause query

2. Keep the below Query in your Query Data Source Name of the Block  CAR_LOAN_INSTALLMENT.

( May be you are equating with null value.)
Use NVL(:LOAN_SYSTEM.REGCODE,0) --Assuming REGCODE as Number. 
If its Varchar2 then use NVAL(:LOAN_SYSTEM.REGCODE,'N/A')
----------------------------------------------------------------------

SELECT ROW_NUMBER () OVER (ORDER BY ROWNUM) SR, LN_DT, PER_MNTH, DEP_CR,
         FIRST_VALUE (LOAN_AMOUNT - DOWN_PAYMENT) OVER (ORDER BY ROWNUM)
       - SUM (PER_MNTH + DEP_CR) OVER (ORDER BY ROWNUM) BALANCE
  FROM (SELECT CAR_LOAN.REGCODE, ROW_NUMBER () OVER (ORDER BY ROWNUM) SR,
               LN_DT, PER_MNTH, CASE
                  WHEN ROWNUM >= 49
                     THEN 0
                  ELSE DEP_CR
               END DEP_CR, LOAN_AMOUNT, DOWN_PAYMENT
          FROM CAR_LOAN, TABLE (LOANINST (CAR_LOAN.LOAN_DATE)))

注意:检查查询是否按预期返回任何结果。

3. Default Where caluse of Block Property keep it as follows:

    REGCODE = NVL(:LOAN_SYSTEM.REGCODE,0)

4. Write a trigger to execute Query

   GO_BLOCK('CAR_LOAN_INSTALLMENT');
   Clear_Block;
   EXECUTE_QUERY;

Note: Also Check the Table Function/Pipelined Function used in the Query (TABLE (LOANINST (CAR_LOAN.LOAN_DATE)).

相关问题