【问题标题】:Oracle forms 10gOracle 窗体 10g
【发布时间】:2020-02-25 11:50:11
【问题描述】:

我是 Oracle 表单的新手,但遇到了问题。 我在表单中有两个具有相同字段的多记录块。

我查询一个块的数据,它被填充了。

在哪里可以将所有行从填充块复制到“复制”块?

【问题讨论】:

    标签: oracle plsql oracle10g oracleforms


    【解决方案1】:

    是的,有办法。一种是在那里手动输入这些值,但这可能不是您想要的。

    另一个是创建一个按钮(我们称之为BTN_COPY)并在其上创建WHEN-BUTTON-PRESSED触发器。它看起来像下面的代码(基于属于 Scott 的EMP 表的项目);请注意,我无法对其进行测试,但是 - 我希望一切都会好起来的。

    declare
      -- local variables; should contain all items you'd want to copy
      l_empno  emp.empno%type;
      l_ename  emp.ename%type;
      l_job    emp.job%type;
      -- l_currec will contain current row number in the first block
      l_currec number := 0;
      -- l_exit will be used if we're at the end of the first block
      l_exit varchar2(1) := 'N';
    begin
      loop
        -- go to the source (first block) and the [last row you were in + 1]
        go_block('first');
        l_currec := l_currec + 1;
        go_record(l_currec);
    
        -- check whether this is the last row of the first block; if so, exit the loop
        if :system.last_record = 'TRUE' then
           l_exit := 'Y';
        end if;
    
        -- save current row's items
        l_empno := :first.empno;
        l_ename := :first.ename;
        l_job   := :first.job
    
        -- go to the second block's bottom and create a new record
        go_block('second');
        last_record;
        create_record;
    
        -- put stored values into the second block's items
        :second.empno := l_empno;
        :second.ename := l_ename;
        :second.job   := l_job;
    
        -- exit the loop if this was the last record to be copied
        exit when l_exit = 'Y';
      end loop;
    end;
    

    【讨论】:

    • 谢谢Littlefoot,但每次按下按钮时,我似乎都陷入了无限循环。为什么会发生这种情况?
    • Littlefoot,我想我稍后再编辑评论,所以你没有看到提到的问题。每次按下按钮时,我似乎都陷入了无限循环。为什么会发生这种情况?
    • 看来你从来没有退出循环。我建议您在该代码中设置一个断点(右键单击左边距,设置断点)并在调试模式下运行表单。执行将在断点处停止,让您一步一步地继续,查看所有变量的值、系统变量等所有内容——然后您就会知道发生了什么。
    • 问题是 :system.last_record 总是返回一个大写的值,所以 "if :system.last_record = 'true' then" 永远不会为真。
    • 很好,@Andy!谢谢。
    猜你喜欢
    • 2014-08-09
    • 1970-01-01
    • 1970-01-01
    • 2010-09-16
    • 1970-01-01
    • 1970-01-01
    • 2012-07-26
    • 2011-03-11
    相关资源
    最近更新 更多