zoukankan      html  css  js  c++  java
  • Checking For User Permissions Before Updating or Inserting The Records in Oracle Forms

    Suppose you want to check the user permissions on inserting or updating the records in Oracle Forms, then you can use Pre-Insert and Pre-Update triggers for that particular data block to check whether user is having proper permission or not.
     
    The example is given for HR schema and the following demo table is created for this:
     
    Create Table User_Permissions (User_Name varchar2(50) Primary Key,
    Can_Insert Varchar2(1) default 'N',
    Can_Update Varchar2(1) default 'N')
     
    Insert into User_Permissions values ('FORMUSER1', 'Y', 'N');
     
    Commit;
     
    Below is the screen shot for the examle:
     
     
    You can download this form from the following link: Pre-Update-Insert.fmb
     
    The following is the code written in Pre-Update trigger to check the permissions from the database:
     
    Declare
    n_allow number;
    begin
    Select 1 into n_allow
       from hr.user_permissions
       where user_name = 'FORMUSER1'
       and can_update = 'Y';
       --- all is well if no exception raised else stop in exception area
       exception
         when others then
            message('You have no permission to update the record.');
            message('You have no permission to update the record.');
            raise form_trigger_failure;
    end;
     
    The following is the code written in Pre-Insert trigger to check the permissions from the database on Insert:
     
    Declare
    n_allow number;
    begin
    Select 1 into n_allow
       from hr.user_permissions
       where user_name = 'FORMUSER1'
       and can_insert = 'Y';
       --- all is well if no exception raised else stop in exception area

       exception
         when others then
            message('You have no permission to insert the record.');
            message('You have no permission to insert the record.');
            raise form_trigger_failure;
           
    end;

    The code is written for Save button:

    Commit_form;
  • 相关阅读:
    【原创】ASP.NET Web开发,实现打印Log日志,步骤详解
    [原创] ASP.NET WEBAPI 接入微信公众平台 总结,Token验证失败解决办法
    Mac安装Linux
    mac下终端的一些命令
    《Python程序设计》题库--摘
    Day 28 类的用法延伸
    Day 27 面向对象补充
    Day 24~26 类,面向对象,属性
    Q 91~100
    Q 81~90
  • 原文地址:https://www.cnblogs.com/quanweiru/p/6220245.html
Copyright © 2011-2022 走看看