zoukankan      html  css  js  c++  java
  • Populating Tabular Data Block Manually Using Cursor in Oracle Forms

    Suppose you want to populate a non-database data block with records manually in Oracle forms. This task can be done using a cursor.
     
    Below is the example given for hr.job_history table, where user input the employee id in upper block and click on the fetch button to populate the records from hr.job_history table into the lower tabular data block.
     
    The following is the screen shot for this example: (you can also download the form from this link Job_History.fmb)
    Follow to get notifications for free source code in future, thanks.
     
    For the employee id field of upper block write the When-Validate-Item trigger code as below:
     
    Begin
    Select first_name||' '||last_name into :ctrl.ename from hr.employees
       where employee_id = :ctrl.empid;
    exception
    when no_data_found then
        message('Employee id does not exists');
        raise form_trigger_failure;
    End;
     

    For the Fetch button write the When-Button-Pressed trigger code as below:

    Declare
    Cursor C_jobs
      is
      Select employee_id, start_date, end_date,
             job_id, department_id
             from hr.job_history
             where employee_id = :ctrl.empid;
    Begin
    go_block('job_history');
    -- first clear the block if it contains any records
    clear_block(no_validate);
    -- move control to first record;
    first_record;
            -- open the cursor and populate the block
    for cur in C_jobs loop
     :job_history.employee_id := cur.employee_id;
     :job_history.start_date := cur.start_date;
     :job_history.end_date := cur.end_date;
     :job_history.job_id := cur.job_id;
     :job_history.department_id := cur.department_id;
     -- move control to next record;
     next_record;
    end loop;
    -- again after completion move control to first record
    first_record;

    End;

    See also: If Value exists then query else create new in Oracle Forms

    Follow To Get Notifications For Free Source Code
  • 相关阅读:
    Linux 配置 nginx + php
    Laravel 网站项目目录结构规划
    配置服务器 Ubuntu 记录+踩坑
    JavaScript 单例,Hash,抛异常
    易理解版八皇后
    获取bing每日图片
    OpenGL 学习笔记 01 环境配置
    [瞎JB写] C++多态
    c++ initialize_list
    最长上升子序列的二分优化
  • 原文地址:https://www.cnblogs.com/quanweiru/p/6220352.html
Copyright © 2011-2022 走看看