Conversion of a delete using the context statement and policies MEV

Hello

I'm trying to convert a delete statement in an update statement using the context and political MEV.

+ / * Assumes that the "user1" user already exists. This is a user of the application * / +.

Conn User1/pwd

create table user1.test_a)
ID number 4,
Description varchar2 (100),
number (1) deleted
+);+

ALTER table user1.test_a add the primary key constraint test_a_pk (id);

insert into user1.test_a (1, 'abc', 0);
insert into user1.test_a (2, 'def', 0);
commit;

I would like to convert each physical deletion a logical removal: instructions such as "delete from user1.test_a where id = 1" must be converted to "day all deleted user1.test_a = 1 where id = 1".»

I found the following way: I create a policy to avoid the physical deletion. In addition, the political function should update the deletion indicator too.

Conn User1/pwd

+ / * Create package context * / +.
create or replace package user1.pkg_security_context is
p_set_ctx of the procedure)
i_test_a_id in % user1.test_a.id type
+);+
end;
+/+

create or replace package body is user1.pkg_security_context
procedure p_set_ctx)
i_test_a_id in % user1.test_a.id type
+) is +.
Start
DBMS_SESSION.set_Context ("user1_ctx", "test_a_id", i_test_a_id);
end;
end;
+/+
display errors

+ / * Create the trigger to put into context before deleting * / +.
create or replace trigger user1.test_a_bef_trg
before you delete the user1.test_a
for each line
declare
pragma autonomous_transaction;
Start
-does not validate the previous update, not deletion that fired the trigger.
commit;

User1.pkg_security_context.p_set_ctx (: old.id);
end;
+/+
display errors

user1_ctx context to create using user1.pkg_security_context;

+ / * Political * / +.
create or replace function user1.f_policy_chk_dels)
object_schema in varchar2,
object_name in varchar2
+) return varchar2 +.
is
out_string varchar2 (400) by default, 1 = 2 ';

+/*+
* out_string is the return value.
*-' WHERE 1 = 2' ' doesn't mean anything for access to.
*/
Start
If (loc_logged_usr_authorized > 0) then
+/*+
* Set the flag removed 1
*/
update of the game user1.test_a deleted = 1 where id = sys_context ('user1_ctx', 'test_a_id');

out_string: = out_string. 'or 1 = 1 ';
end if;

Return out_string.
end;
+/+
display errors

+/*+
Create policies
*/
Start
() dbms_rls.add_policy
object_schema = > 'user1 ',.
object_name = > "test_a"
POLICY_NAME = > "policy_chk_dels"
function_schema = > 'user1',-function scheme
policy_function = > 'f_policy_chk_dels', - function policy
statement_types = > 'DELETE '.
+);+
end;
+/+

When I try to delete a record from the table test_a:

Conn User1/pwd

SQL > delete sim ilogdia.oplsimulaciones where sim.id = 9999;

+ 0 rows deleted.

No row has been deleted, but the update stmt does not work. This means that the 'deleted' flag has not been updated.

Any ideas?

Thank you in advance.

Marco A. Serrano

Published by: albrotar on October 15, 2012 08:42

Published by: albrotar on October 15, 2012 08:42

Published by: albrotar on October 15, 2012 08:43

The policy function is applied once per execution of the statement. The political function executes first, and the UPDATE statement updates probably, no line because the context is not yet filled. The level of the line fills the frame (I'm assuming that your session may even see context values populated by autonomous transaction - I guess it's possible, but I have to test this) after the UPDATE statement is already complete. VALIDATION in the row-level trigger is also useless - it does that to changes made by the current transaction that is independent, of which there is none--it cannot apply to changes made in the other autonomous transactions. Declaring the level line trigger to use autonomous transactions does not seem to do anything other than to open the question of whether the values defined under the autonomous transaction are visible in the transactions of the appellant.

Even if, somehow, did not work, the use of transactions autonomous would be a very bad idea because Oracle is free to roll back a partially executed query (and the work done by its triggers) and re - run. Oracle does with some regularity to maintain the consistency of Scripture.

Justin

Tags: Database

Similar Questions

  • How can I access my computer in order to remove downloaded files that has not deleted using the control panel and the usual functions to delete?

    I recently received from remote assistance installed a new anti-virus program. During using the remote technician, I he observed several open windows because it deleted the files that were left by previous anti-virus programs on my computer.  These files prevent the download of the new program.  As I watched him navigate through my programs and files, I noticed that there are a lot of game files that have been deleted by using the functions of the control panel and uninstalling still in my computer.  The technician of 3-4 programs installed on my computer while he removed residual files of the antivirus and promptly removed from these programs when it was correctly installed my new anti-virus program.  I would really like to know how to access files or records what he did and then delete the game files that I thought were removed.  I downloaded at least 100 trial offers for sets of objects hidden over the years and you don't want no trace with my memory of the computer.  No help available out there?

    Hey,.

    You can follow this link to recover lost or deleted files:

    http://Windows.Microsoft.com/en-us/Windows-Vista/recover-lost-or-deleted-files

    also, look for the file/game:

    http://Windows.Microsoft.com/en-us/Windows-Vista/save-your-search-results

    Hopefully this should help you.

  • I use Firefox for a kiosk application. Can I disable the context menu and zoom?

    I use Firefox for an application kiosk on a touch screen monitor. I will prevent users from interacting with the browser interface. Is there a way to do this? Disable the context menu and zoom for the touch gestures could prevent users from getting into a State where they are unable to use the application.

    Hi TrevorTubbs, you can disable the zoom in the browser with the method described in http://kb.mozillazine.org/Locking_preferences & locking these preferences:

    lockPref("toolkit.zoomManager.zoomValues"; "1");
    lockPref("zoom.maxPercent"; 100);
    lockPref("zoom.minPercent"; 100);
    

    I'm not sure if disabling the context menu...

  • How to get the "Run as different user" option using the context Menu

    I work with the domain environment and use os win 7 but it do not display "run as user deffrent' so, how get the"Run as a different user"option using the context Menu, share pls burned discription.

    (also try pressing shift + right click but nothing else)

    Atul Rai

    E-mail address is removed from the privacy *.

    May be of help to the: http://www.sevenforums.com/tutorials/155532-run-different-user-without-shift-right-click-context-menu.html

  • I have the table of 3 columns A, B, C. I want to store the sum of columns A B in the C column without using the DML statements. Can anyone help please how to do. ?

    I have the table of 3 columns A, B, C. I want to store the sum of columns A B in the C column without using the DML statements. Can anyone help please how to do. ?

    11.1 and especially you have virtual column

    SQL> create table t
      2  (
      3     a number
      4   , b number
      5   , c generated always as (a+b) virtual
      6  );
    
    Table created.
    
    SQL> insert into t (a, b) values (1, 2);
    
    1 row created.
    
    SQL> select * from t;
    
             A          B          C
    ---------- ---------- ----------
             1          2          3
    

    Before that, a front insert - trigger

    SQL> create table t
      2  (
      3     a number
      4   , b number
      5   , c number
      6  );
    
    Table created.
    
    SQL> create or replace trigger t_default before insert on t for each row
      2  begin
      3    :new.c := :new.a+:new.b;
      4  end;
      5  /
    
    Trigger created.
    
    SQL> insert into t (a, b) values (1, 2);
    
    1 row created.
    
    SQL> select * from t;
    
             A          B          C
    ---------- ---------- ----------
             1          2          3
    
  • Can I buy CC in the United States and use it in Europe?

    I work in part to the United States and in part here in Europe. There is such a disparity in price it is interesting of my buying members of the CC, in Los Angeles, putting on my laptop, it helps the United States and placing it on my desktop PC when I come back here. I can do this, or is there some kind of 'recognition' regional? Do I need two memberships?

    Hi Nick

    You must register using an Adobe ID & credit card that is registered in the same country.  When you have done this, it is possible to use the membership if you travel to a different country.

    Thank you

    Bev

  • How to use the context of spring to the sca

    Can Hi anyone tell me how to use the context of spring in bpel and how the context of spring in composite service feature architecture (sca)

    Envoy

  • How to pass parameter in the function using the select statement?

    Hello

    I had a problem. I can't pass as parameter to the function by using the select statement. But it can pass as a parameter using the "code". How can I solve this problem?

    For example,.
    Select * from table (SplitFunction ('HS750020, HS750021')) < < < this work.

    but

    Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) < < < do not work.

    Thank you for trying to help him. Thank you.

    Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36'))< do="" not="">

    Try like this

    select * from table(select splitfunction(lot_no) from tracer_search_schedule where job_id='36')
    

    Just make sure that your subquery returns only 1 row.

  • form using the trial version and it continues to repeat the information to a page (either first or last page) to all pages and deleted the contents entered in

    form using the trial version and he continues to repeat the information of a page (either first or last page) to all pages and remove the content that has been entered into.

    The fields with the same name will be the same content. You must change the names of the fields.

  • I have an Apple computer, use the browsers Firefox and Safari, use Comcast for my email. Lately, when the Firefox, my email does not work correctly. Why?

    I have an Apple computer, use the browsers Safari and Firefox. I use Apple mail and Comcast to my email. Lately, in the case of Firefox, my email does not work correctly. I get a message "your server license has expired. While usually, I can access my emails, I can't delete the unwanted emails. This problem will not occur when I use Safari and Apple mail. Is this a problem of Firefox or Comcast? Do you know what license is expired?

    Hello

    Many issues of the site can be caused by corrupted cookies or cache. To try to solve these problems, the first step is to clear cookies and cache.
    Note: This will be you temporarily disconnect all sites, you're connected to.
    To clear the cache and cookies to do the following:

    1. Go to Firefox > history > clear recent history or (if no Firefox button is displayed) go to tools > clear recent history.
    2. Under "Time range to clear", select "all".
    3. Now, click the arrow next to details to toggle the active details list.
    4. In the list of details, see the Cache and Cookies and uncheck everything.
    5. Now click the clear now button.

    More information can be found in article to clear your cache, history, and other personal information in Firefox .

    This solve your problems? Please report to us!

    Thank you.

  • I WISH THAT ALL PAGES TO FIT ON MY SCREEN SO I CAN'T USE THE ARROW LEFT AND ARROW RIGHT! THANK YOU VERY MUCH FOR YOUR HELP!

    MY PAGES HAVE BEEN VERY WELL UNTIL I DOWNLOADED SOMETHING, I DON'T KNOW EXACTLY.   I THOUGHT I TRY TO DELETE WHAT I DOWNLOADED ARRIVE TO WHERE I WAS, BUT I DON'T THINK IT WORKED OR I DELETE ANYTHING!  SO I'M GOING TO STILL USE THE ARROW LEFT AND ARROW RIGHT TO VIEW ALL PAGES.  I WENT TO CONTROL PANEL, DISPLAY, SETTINGS, WENT TO A HIGH NUMBER TO THE PIXEL NUMBER LOW, CE WHICH WAS THE ONLY SOLUTION POSSIBLE, AND ALL GROW.  SO I PUT IT BACK TO THE LOT WHERE HE WAS!  DON'T KNOW WHAT TO DO, SO HERE I AM ASKING FOR HELP!  Thank you!!!  MY email * address email is removed from the privacy *.

    First remove everything you have installed, check if it works.

    In case of failure and then update the display on the computer drivers

  • Every time using the ', it displays "and «»

    original title: why is my ' button always keep changing?

    A simple problem I guess, but as a writer, it is very annoying.  Whenever I'm trying to use the ', it displays "and" "when I hold down the SHIFT key.  I have to delete the extra apostrophe to an apostrophe.  How can I change, so it's a single apostrophe instead of quotes at all times.  I played with the language toolbar and every time I spend in the US instead of US International, it fixes the problem... only temporarily.  How can I make it permanent?  Thanks for the help in advance.

    Hi Spundae,

    Welcome to the Microsoft Community and thanks for posting the question.

    According to the description, it looks like a character is typed when you use a single apostrophe.

    I have a link that should guide you in the right direction.

    Visit the link and indicate "the keys do not collide correctly" and "the wrong characters are typed.

    http://support.Microsoft.com/kb/258826

    Keep us updated on the status of the issue. For any help about Windows, you can still post on the Microsoft Community.

  • How do I use the letters A and O in Dreamweaver?

    I wonder if there is any way I can use the letters A and o Dreamweaver transforms the letters some random mess. They are used in my mother tongue and so far I have not been able to use. I can't also set with change the language of Dreamweaver on my own since it was translated to it. Are they fixed if I download my files on the net? If this is not the case, what I have to do to fix this?

    Yes, you can use the accented characters in Dreamweaver, as long as you use a fairly recent version of Dreamweaver. Make sure that the document encoding is set to UTF - 8. If you can type accented directly from your keyboard characters, Dreamweaver inserts the characters directly.

    What you describe as back "some random mess" at the time where the browsers are not able to handle accented characters. Ä is the character entity HTML a. Older versions of Dreamweaver by default to Western European (iso-8859-1 encoding), which translates accented characters in the process of conversion to HTML character entities.

  • I live in the United States and would like to buy a song from the Germany. Is this Possible?

    I live in the United States and would like to buy a song from the Germany. Is this possible?

    Hello

    You can buy songs that are available on iTunes Store for your country.

  • Using firefox 14.0.1. Load a link using the right click and "Open link in new window", translates into a new window opens but doesn't show URL address bar...

    Using firefox 14.0.1. Load a link using the right click and "Open link in new window", translates into a new window opens but doesn't show URL address bar. However, if I click with the right button on a link and select "Open link in a new tab", the tab displays the URL in the address bar. If it works when a new tab it's not in a new window.

    The reset Firefox feature can solve a lot of problems in restaurant Firefox to its factory default condition while saving your vital information.
    Note: This will make you lose all the Extensions, open Web sites and preferences.

    To reset Firefox, perform the following steps:

    1. Go to Firefox > help > troubleshooting information.
    2. Click on the button 'Reset Firefox'.
    3. Firefox will close and reset. After Firefox is finished, it will display a window with the imported information. Click Finish.
    4. Firefox opens with all the default settings applied.

    Information can be found in the article Firefox Refresh - reset the settings and Add-ons .

    This solve your problems? Please report to us!

Maybe you are looking for