Implement conditional read-only column in the set of two Tables

Hello

I would like to implement a mechanism of "read-only conditional" on a column in a table with two tables in total to be involved in this situation.

I have a demo/proof of concept of the present and things work as expected in the tests I've done; However, I would like any input as to if there is a better way, etc.

This is a far-fetched but demo that illustrates the main ingredients however. Oracle 10.2.0.4 version 64 bit on Windows Server 2008 Release 2 64-bit.

-Table DDL and small sample data
create table band(
  band_id   number primary key,
  band_name varchar2(20),
  status    varchar2(20)
);

create table band_member(
  band_id references band,
  member_name varchar2(20)
);

insert into band values(3, 'The Rutles', 'prefab4');
insert into band values(4, 'The Beatles', 'established');
commit;

insert into band_member values(3, 'Ron Nasty');
insert into band_member values(3, 'Dirk McQuickly');
insert into band_member values(3, 'Stig O''Hara');
insert into band_member values(3, 'Barrington Womble');
commit;

insert into band_member values(4, 'John Lennon');
insert into band_member values(4, 'Paul McCartney');
insert into band_member values(4, 'George Harrison');
insert into band_member values(4, 'Ringo Starr');
commit;
-The rules relating to the conditional objective of read-only

1 is not allowed to update band.band_name when band.status = 'prefab4'
2 is not allowed to insert/update / deletion of lines of band_member when the parent a band.status row = 'prefab4'

-The triggers used to implement the goal (current solution)
create or replace trigger t1
before update of band_name on band
for each row
when (old.status = 'prefab4' or new.status = 'prefab4')
begin
  raise_application_error(-20010,
    'can not update band_name when status=''prefab4''');
end;
/

create or replace trigger t2
before insert or update or delete on band_member
for each row
declare
  l_status band.status%type;
  l_band_id band_member.band_id%type;
  cursor l_cursor (p_band_id number) is
  select status from band
  where band_id = p_band_id
  for update;
begin
  if updating or inserting then
    l_band_id := :new.band_id;
  else
    l_band_id := :old.band_id;
  end if;
  open l_cursor(l_band_id);
  fetch l_cursor into l_status;
  close l_cursor;
  if l_status = 'prefab4' then
    raise_application_error(-20011,
      'can not update child when parent status=''prefab4''');
  end if;
end;
/
-Quick example of test for each condition
update band
set    band_name = 'THE RUTLES'
where  band_id = 3;

update band
       *
ERROR at line 1:
ORA-20010: can not update band_name when status='prefab4'
ORA-06512: at "DEMO.T1", line 2
ORA-04088: error during execution of trigger 'DEMO.T1'


update band_member
set    member_name = 'RON NASTY'
where  member_name = 'Ron Nasty';

update band_member
       *
ERROR at line 1:
ORA-20011: can not update child when parent status='prefab4'
ORA-06512: at "DEMO.T2", line 18
ORA-04088: error during execution of trigger 'DEMO.T2'
As I said, while my simple tests seem to show the correct results, there I was wondering if there could be a better way to implement such functionality.

I tried to provide the information needed, but if I managed to omit something, please let me know.

See you soon,.

Chalfont

Hi, Chalfont,

user13146957 wrote:
...
I'm went to the road to slider to add the clause "for update" to force the serialization on the line - i.e. the idea was to avoid the case where another session might want to update the State a moment after my extraction but before the rest of the finished code. Who is?

No, not really. The trigger on tape prevents anyone else from ever change their status from 'prefab4' to something else (or vice versa).
Even apart from this, you put some efforts to prevent something which will be allowed a fraction of a second later (or maybe the other way around). What is significant in that split second?

I didn't think about other ideas rather than the approach of the trigger, but came up empty, somehow, to this day. I am open to resort to others and make some schema changes is not off the table either.

FGA (Fine grain access), or his brothers and sisters more older VPD (virtual private database) can also do what you want, but instead of trigger an error, they ignore the illegal action. This can be an advantage or a disadvantage, depending on your needs.

Another approach is for the owner of the table, not to grant INSERT, UPDATE or DELETE privileges to anyone: all DML must be made via a procedure (or procedures) belonging to the owner of the table, which grants EXECUTE privileges instead of other privileges.

Tags: Database

Similar Questions

  • Dynamically set read-only columns in the tabular presentation at record levels

    Hello

    Is it possible to activate and deactivate fields at the level of the line in a tabular presentation... I use OFA to create a page that should give the possibility to activate and deactivate certain fields in the table on the fly...

    Here's the requirement:

    examples of data

    Item_code |   Review | Point Attrib1 | Article attrib2 | Article attrib3 | Columna | ColumnB

    1.234               100           A                         B                    _                  A               _

    1.235               100          B                              _                 B                 _                   A

    fields point attrib3 and Columnb should be read-only if the value of attrib1 point is A

    Even if point value attrib1 is B columna and attrib2 of the element must be read-only...

    I have PPR on item_attrb1 to manage the change of value in the attrib1 element, but I'm not able to make fields read only at the level of the line... Please help me if someone has work around this

    Is this possible?

    Thank you

    Dilip

    Hello..

    It is possible. Made myself.

    You must use SPEL for this.

    Steps to follow:

    1. the Caisse one type of transitional say as Boolean column ReadOnly

    2 set the Readonly property for that column as ReadOnly

    (Syntax FRO SPEL-> {oa. VO. ReadOnly})

    3 al ' PPR after checking the status, the ReadOnly Anaïs value accordingly.

    .

    You can get the idea here.

    https://blogs.Oracle.com/manojmadhusoodanan/entry/hiding_an_item_conditionally_through

  • How could put editable report column as read only based on the other domain

    Hello world

    I'm new to APEX. I have a modifiable tabular report (SQL query). When I choose the column (which is a selection list) of a certain value, I want column B to be read-only (depending on the result of an another SQL described below). It doesn't seem to be a READ ONLY section in the type of tabular report where I could put my SQL condition.

    In other words, "column B" must be read only based on SQL returning following true or Exists:
    Thus, to determine if column B is ready only, I need the following logic:

    SELECT 'x '.
    of tab1
    where key = (value of column A)
    and the flag = "Y".

    Any help would be greatly appreciated!
    Thank you
    François

    You can only do so if your tabular presentation is a manually created. In this example, it shows how to set this property:

    http://Apex.Oracle.com/pls/OTN/f?p=31517:170

    You can use a case statement to set this property for specific lines.

    SELECT empno,
           CASE
              WHEN ename LIKE 'A%'
                 THEN apex_item.text
                                  (34,
                                   job,
                                   80,
                                   100,
                                   'style="width:170px" readonly="readonly"',
                                   'f34_' || '#ROWNUM#'
                                  )
              ELSE apex_item.text (34,
                                   job,
                                   80,
                                   100,
                                   'style="width:170px"',
                                   'f34_' || '#ROWNUM#'
                                  )
           END job
      FROM emp
    

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
    -------------------------------------------------------------------

  • Is this a bug? HTML is not escaped in the conditional read only LOV page elements

    Then test my application for injection HTML filling HTML for each column in my data injected datamodel HTML running when a field only LOV ready, I noticed



    I have dynamic LOV in use in my form, so their share, users can select. That sometimes I don't want to make them able to change a value, they chose earlier.

    For this reason I condtionalu readonly my LOV. by using the conditional read only an option for the items on the page.



    That's when a dynamic LOV made readonly HTML code inside is done instead of escaped



    is this a bug or is it intentional?

    At least, I think I should be able to choose the behavior.



    Geert

    Geert - Thanks for the info. I think that's not a bug. With the read-only option, it displays the data as it would for a display text (does not save the State) items for which source of HTML element, that is, unescaped. If you want the text escaped by using your dynamic lov query simply use htf.escape_sc:

    Select htf.escape_sc ('data') d, 1 r of the double

    Scott

  • You have read-only access to the inventory of the Oracle

    I try to install on the AIX machine, I get the below error please help

    Hostname resolved - xxxxxx
    Supported operating system - AIX
    You have read-only access to the inventory of the Oracle
    Failure to meet all the prerequisites can lead to unsatisfactory results. If you have errors, please see the help or documentation for more information.

    There is a file. Oracle.properties which is an inventory of the oracle. Search and find which directory it is located, you may need to change the permissions to have full access. It is used during the installation to determine which products can be installed and what needs to be upgraded

  • Read only access to the database

    Hi all

    I am unable to give read-only access to a newly created in the Oracle database user. I grant only read permission to the user, but the problem, it's that this user is able to delete data from a table or schema.

    Must only give 'Read only' access to the user who will be sql query for any table, schema, etc.


    I followed the steps.

    1 creation of the user

    2 granted suite privilege

    CREATE SESSION

    SELECT_ANY_TABLE;

    SELECT_ANY_DICTIONARY

    Please guide on the same.

    user8934591 wrote:
    Hello

    I created the user "MFC".

    and granted 'create the Session '.

    Thank you and best regards,

    Fine. But I asked PUBLIC.

  • Setup error: you have read-only access to the inventory of oracle

    Hi guys,.

    In some versions of Linux, for example. Fedora, Ubuntu... every time I install the Hyperion product, I get this error "you have read-only access to the oracle inventory." and also the interesting thing, if this error comes Oracle does not settle "OpenLDAP' which is required to run shared services.

    With Oracle Enterprise Linux, and everything seems fine. and I did not get the above error also OpenLDAP is installed.

    any help would be appreciated. attached is the screenshot of the error.

    [https://docs.google.com/leaf?id=0BwB5xiYJ_HGwMDZkNjQ1OTEtMDg4Zi00NGM3LTk5NDAtYzE1ZmJkZTcyMzU0 & hl = en]

    Thank you

    Supported versions of linux, with you have found problems.
    I thought it was just Oracle Enterprise 4/5 and Red Hat Enterprise 4/5 that are supported.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Search multiple criteria information in the column on the left of a table.

    How to search several criteria information in the column on the left of a table. I am familiar with /match index search values of the left columnn in a table for a "single" column, but not for more than one column?

    Hello

    It seems that you are using Microsoft Office Excel. If yes then it would be better suited in the community of Microsoft Office Excel. I would recommend posting your query in the community of Microsoft Office Excel.

    Microsoft Office Excel community

    http://answers.Microsoft.com/en-us/Office/Forum/Excel

     

    Hope this information helps.

  • Kindly help me with the request to find the data in two tables

    Hello Guru

    Kindly help me to recover the data from two tables-

    BASEBALL
    LEGAL_ENT_ID (PK)
    GAME_ID (FK)
    LEGAL_ENT_NM
    INACTIVE_DT
    DATE OF INS_TS
    INS_LOGIN
    DATE OF UPD_TS
    UPD_LOGIN


    FOOTBALL
    GAME_ID (PK)
    BRKR_NM,
    BRKR_ISR_ID
    BROKER_SYMBOL
    INACTIVE_DT
    BRKR_SWIFT_FLG
    BRKR_INTERNAL_FLG
    BRKR_CATEGORY
    UPD_TS
    MINORITY_FLG
    BROKER_TYP
    STATUS
    INS_TS
    INS_LOGIN
    UPD_LOGIN
    APP_USER
    ACTIVE_FLG

    and if I want fecth data from these two tables according to the following condition then it is fine with the suite of applications.

    1 select distinct values only table of BASEBALL by using the following query.

    SELECT DISTINCT B.GAME_ID as 'CLEARING GAME ID', B.BRKR_NM "NAME of THE GAME of COMPENSATION" OF BASEBALL A, FOOTBALL B WHERE A.BROKER_RELATION_CD IN ('FUTBRKR1', 'FUTBRKR2') AND A.GAME_ID = B.GAME_ID

    2 Select all the table BRKR_NM OF FOOTBALL as well by using the query - next

    SELECT GAME_ID "RUNNING GAME ID", 'NAME OF THE GAME OF EXECUTION' BRKR_NM SOCCER

    Now, my query is that--

    I want a query that gives me a combination of above mentioned queries... and if I tried to use Union or Union All, then she is not giving me the result as expected.

    I like the result to look like who has a few conditions such as -
    1 - the records in the table Football are high vs Baseball table because there is no condition to filter the records of the Football.
    2 - football is a superset of records and Baseball is a subset.
    3 - COMPENSATION NOM_JEU and RUNNING NOM_JEU may return the same values as well.

    I want the result to be in the following form-

    EXECUTION ID GAME | NAME OF THE GAME TO RUN. COMPENSATION ID GAME | DELETE THE NAME OF THE GAME.
    2123 test1 2345 test5
    2456 test10 2456 test10


    Thanks in advance. Kindly help me.

    Published by: user555994 on January 4, 2011 23:48

    In the output you want.
    All the values of baseball;
    Values of football that are matched;
    But on what condition you want to match?

  • How it warns Oracle to use an index for the join of two tables...

    How to prevent the Oracle to use an index for the join of two tables to get a view online that is used in an update statement?

    O.K. I think I should explain what I mean:

    When you join two tables that have many entries sometimes there're better is not to use an index on the column that is used as a criterion to join.

    I have two tables: table A and table B.

    Table A has 4,000,000 entries and table B has 700,000 entries.

    I have a join of two tables with a numeric column as join criteria.

    There is an index on this column in A table.

    So I instead of
      where (A.col = B.col)
    I want to use
      where (A.col+0 = B.col)
    in order to avoid Oracle using the index.

    When I use the join in a select query, it works.

    But when I use the join as inline in an update statement I get the error ORA-01779.

    When I remove the '+ 0' the update statement works. (The column is unique in table B).

    Any ideas why this happens?

    Thank you very much in advance for any help.

    Hartmut cordially

    You plan to use a NO_INDEX hint as shown here: http://www.psoug.org/reference/hints.html

  • Conditional read only the rows in a table

    We have a requirement only under a certain condition (which may change each line), a line can be read only or editable and are uncertain how to implement this with APEX

    for example, lets say a table has the following features

    columns: ID, Date, editable

    1, September 12, 2015, Y

    2, September 15, 2015, Y

    3, 18 September 2015, N

    4, 19 September 2015, N

    5, 22 September 2015, Y

    Thus, when this data displays on a page in a tabular presentation, the date ONLY are editable for lines 1, 2 and 5. For lines 3 and 4, the date cannot be changed

    In the ADF, we get this by setting the attribute readonly on the date component to "row.bindings.Editable.inputValue =='N" ""-this would be evaluated by line and switch read only one or off for each date listed in the table.

    Help, pointers would be greatly appreciated!

    See you soon,.

    Brent

    Here is a link to a starting point: dynamic Action on a tabular presentation. Jeff Kemp on Oracle it shows how to condition the unalterable columns.  The same logic would apply only to a line level...

    Thank you

    Tony Miller
    Los Alamos, NM

  • Field read only based on the authorization form

    Hello

    I have a field in a tabular presentation read only based on a permission scheme, as you can for a field in the region with the help of a condition of PL/SQL. Is it possible to do this?

    See you soon,.
    Andrew.

    Hi André,.

    Caught this idea,

    Please create a plus column within the report using as "alaisecolumnname" then

    column with editable text for authorization schema [ISADMIN] box
    draw sheet column with displayonlytext for authorization shcema [NOTISadmin]

    I hope that it will match your expected results, I tested it in my workspace works very well for me

    Thank you
    Select this option.

  • I am trying to remove the "read only" attribute of the file, that I had just downloaded in Windows Vista

    Original title: administrative account - change a read-only file

    Administrative account: I would like to change a file I am trying to download on my computer.  I don't know how my administrator account to change the file, I am trying to open - fly a read-only.

    Hi auddie,.

    1. What is the error you get when you try to open the file?

    I suggest that you take the file and check.

    a. right click on the file you want to take control and then click Properties.
    b. click the Security tab and then click OK on the security message (if one appears).
    c. click Advanced and then click the owner tab.
    d. in the name list, click your user name, click Administrator, if you are logged in as administrator, or click the Administrators group. If you want to take ownership of the contents of the folder, select the replace the owner of sub containers and objects check box.
    e. click OK and then click Yes when you receive the following message is displayed:

    You are not allowed to read the contents of directory folder name. Do you want to replace the the directory permissions with permissions granting you full control?

    All permissions will be replaced if you click Yes.

    Note: the name of the folder is the name of the folder you want to take charge.

    . Click OK, and then re apply the permissions and security settings that you want for the folder and its contents.

    Reference:

    Appropriating a file or a folder

    Aziz Nadeem - Microsoft Support

    [If this post was helpful, please click the button "Vote as helpful" (green triangle). If it can help solve your problem, click on the button 'Propose as answer' or 'mark as answer '. [By proposing / marking a post as answer or useful you help others find the answer more quickly.]

  • read only cells in the form of data

    Hello

    A couple of lines become read only in one or more the data form, it is read only for some users AB and its writable for users CD.

    AB users could not enter data until last month in the same lines on the same form, all of a sudden it does not AB enter data in cells.

    If security seems good, what could be other possible questions?

    Thank you

    Ravi

    Did you look at their security? Check the filters in environmental assessments or generate a report of access control for users and see if some security is limiting.

    Concerning

    Celvin

  • PDF form javascript to read only field using the button

    Please let me know the PDF form JavaScript to make the selected fields (text field, dropdown list, etc.) read-only button.

    Do you want your button to read-only?

    Let's start with Acrobat JS Reference.

    do all the fields in a form read-only;

    var oField; variable field processing;

    Browse the form fields;

    for (var i = 0; i)< this.numfields;="" i++)="">

    treat each domain name;

    oField = this.getField (this.getNthFieldName (i)) .readonly = true;

    }

Maybe you are looking for