Newbie Trigger question - before delete

We have a table A - Primary Key A1, and Table B has a column B1 foreign key to A1 column.
We need to mass delete table A records which are more than 3 months old, but we do not want to delete Records from Table B, just nullify the foreign key column in table B.
So "ON DELETE CASCADE" is not applicable in our situation. Is creating a trigger with before delete option the only way to solve the above?
If yes, when inside the trigger action, how can I access the table A primary key value to find out if I have a possible match in table B? How to represent (current rows's A1 value) ?
For example - trigger action
CREATE TRIGGER DEL_A
BEFORE DELETE ON A
FOR EACH ROW
DECLARE X;
BEGIN
    SELECT COUNT(*) INTO X
    FROM B WHERE B1 = (current row's A1 value);
    IF X > 0
    THEN
       UPDATE B SET B1 = NULL
       WHERE B WHERE B1 = (current row's A1 value);
   END IF;
ENDIs the above code correct, or is there any better way to do the same?
Thanks in advance,
Rumpa

where B1 = :A1
You probably mean "where b1 = :old.a1" ...
Regards,
Rob.

Similar Messages

  • Newbie setup questions before I accidently wreck something, please!

    Hi, I have a brandnew Macbook white. My IP is MSN and I'd like to know how to access the email in MSN Explorer?
    Is there a way to transfer my favorites in MSN to bookmarks in Mac?
    If I set up a MAC email, is there a charge for that? Do I tell everyone a new email address?
    Does the internet screen ever cover the whole desktop? Mine is rather small but I don't want to change the resolution to enlarge it.
    Thanks for any help; I'm afraid to change any parameters in case I wreck something, never having been a Macgirl before!

    LadyCork wrote:
    Hi, I have a brandnew Macbook white. My IP is MSN and I'd like to know how to access the email in MSN Explorer?
    See this for help on Mail set up for the MacBook. http://www.apple.com/support/tiger/mail/
    Is there a way to transfer my favorites in MSN to bookmarks in Mac?
    Go into explorer and under File choose *Import and Export*. Pick *next in the window that pops up. From the choices choose *Export Favorites* then Next. Hit Next in the next window. Choose where you want to put the file. Then push Next and then Finish.
    Now move the file so you can get to it from your MacBook. Open Safari and under File choose *Import Bookmarks* click on the file and they should import to Safari.
    If I set up a MAC email, is there a charge for that? Do I tell everyone a new email address?
    See this for more info on .MAC http://www.apple.com/dotmac/
    Does the internet screen ever cover the whole desktop? Mine is rather small but I don't want to change the resolution to enlarge it.
    Drag the following Java script to your Safari bookmarks toolbar and name it what you want. Then when you click it it will be full screen. This also work on SeaMonkey, OmniWeb and FireFox.
    javascript:self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);

  • Get Current SQL in Before delete trigger

    Hi,
    I have created a before delete trigger to track which records are deleted from a table I need to know what statements fires the trigger. can someone please describe how I can retrieve the current SQL.
    using sys_context('userenv','CURRENT_SQL') returns null for CURRENT SQL
    Note:
    For me the easier is to enable auditing and audit delete on the table however at the moment I cant get a downtime from the business to bounce the database to enable auditing.
    CREATE OR REPLACE TRIGGER before_delete BEFORE DELETE
    ON AUDIT_TEST_TAB
    FOR EACH ROW
    DECLARE
    v_username varchar2(50);
    v_stmt varchar2(255);
    v_client_info varchar2(200);
    v_os_user varchar2(50);
    v_machine varchar2(50);
    v_program varchar2(50);
    v_module varchar2(50);
    v_auth_type varchar2(200);
    v_ip_addr varchar2(200);
    v_sql_statement VARCHAR2(4000);
    BEGIN
    SELECT sys_context ('USERENV', 'CURRENT_SQL')
    INTO v_sql_statement
    FROM dual;
    -----------insert into logging table statment ----
    end;

    A few comments.
    Lets assume you run a delete statement that deletes 550 rows from your table. If your trigger is working then the very same statement would be stored 550 times. I think an BEFORE or better an AFTER delete STATEMENT level trigger would be the better choice. Why AFTER? Because if the delete operation fails, for example because of existing child records, then everything is rolled back anyway to the implicit savepoint just before the delete.
    So to store the SQL statement the correct trigger would be an AFTER STATEMENT DELETE trigger.
    Now what to store: You want the sql statement. You could try to find the cursor/currently running SQL. It might be tricky to separate that from the SQLs that you run to find this out.
    It could even be possible to simply save all commands that are in your PGA/Cached cursor area. First find out yur session, then store the SQL_text (first 60 chars) for all the cursors in this session by using v$open_cursor or the first 1000 chars by using v$sql.
    Here are a few views that might be helpful. v$session , v$open_cursor, v$sql, v$sqltext, v$sql_bind_data, v$sql_bind_capture, dba_hist_sqltext

  • Before delete trigger?

    We are trying to determine who (like in what applicaton) is deleting rows in one table that leaves "orphaned" rows in another.
    We create the following trigger...
    create or replace Trigger EFA_TRG_AUDIT
    before delete on EFA_EXTERNAL_FILE_ATTACHMENT
    for each row
    declare
    OS_USER varchar2 (20);
    HOST varchar2 (20);
    MODULE varchar2 (48);
    SESSION_USER varchar2 (20);
    Begin
    if :old.EFA_LDS_UID is not null then
    SELECT substr(SYS_CONTEXT ('USERENV', 'SESSION_USER'),1,20) into SESSION_USER from dual;
         SELECT module into MODULE from v$session where audsid=userenv('SESSIONID');
         SELECT substr(SYS_CONTEXT ('USERENV', 'HOST'),1,20) into HOST from dual;
         SELECT substr(SYS_CONTEXT ('USERENV', 'OS_USER'),1,20) into OS_USER from dual;
    insert into EFAA_EFA_AUDIT values(
         :old.EFA_UID,
         :old.EFA_SYT_CODE_PARENT,
         :old.EFA_PARENT_KEY,
         :old.EFA_SEQUENCE,
         :old.EFA_FILENAME,
         :old.EFA_DESC,
         :old.EFA_LDS_UID,
         :old.EFA_CREATE_DATE,
         :old.EFA_USR_UID_CREATED_BY,
         :old.EFA_LAST_UPDATE_DATE,
         :old.EFA_USR_UID_UPDATED_BY,
         :old.EFA_FAT_CODE,
         :old.EFA_FILE_SIZE,
         'DELETE',
    HOST,
    OS_USER,
         MODULE,
    User,
         Sysdate);
    end if;
    end;
    This will create an "audit table" which works fine but includes ALL deletes including valid deletes that leave no "orphans" (EFA_LDS_UID).
    The LDS table can have rows that are not related to the EFA so a constraint cannot be used.
    Any ideas?

    no need to clean up the data. just create the FK as NOVALIDATE
    from the SQL Reference manual:
    ENABLE NOVALIDATE ensures that all new DML operations on the constrained data comply with the constraint. This clause does not ensure that existing data in the table complies with the constraint and therefore does not require a table lock

  • How to make before delete trigger

    Hi all
    I want make before delete trigger
    I have 2 tables hr_api_transactions and new_table
    when I delete records from hr_api_transations table
    then that deleted record should be stored/insert in new_table table
    for that purpose I need before delete trigger
    How can I make It?

    Hi
    I have written following code but it gives an error
    CREATE OR REPLACE TRIGGER before_delete_trigger
        BEFORE DELETE
            ON HR_API_TRANSACTIONS
            FOR EACH ROW
        DECLARE
        BEGIN
            delete from new_table where new_table.name = OLD.hr_api_transactions.api_addtnl_info;
        END;
    TRIGGER BEFORE_DELETE_TRIGGER compiled
    Errors: check compiler logafter show errors it shows
    4/54 PL/SQL: ORA-00904: "OLD"."HR_API_TRANSACTIONS"."API_ADDTNL_INFO": invalid identifier
    4/9 PL/SQL: SQL Statement ignoredhere hr_api_transaction is table which contain API_ADDTNL_INFO column
    and name column of new_table and API_ADDTNL_INFO column of
    HR_API_TRANSACTIONS table are same

  • The QoS retains a notification for a limited period before deleting it. My question is, how long is this notification retain?

    The QoS retains a notification for a limited period before deleting it. My question is, how long is this notification retain?
    Can we have a lost problem if we havent wi-fi or 3g for a long time?
    Thanks for your help!

    Problem Resolved - it is a font issue. Apparently Acrobat can't handle particular fonts and it is best to stick with a very small slection of fonts - Arial, Helvetica, Times Roman.
    I haven't test a lot of fonts. If I do, I'll post there results here.
    Bob

  • Before delete trigger and foreign key relationship

    Hi,
    I am analysing one database for migration. On one parent table there is before delete trigger , to delete records from child. Also there is foreign key relationship on child table for this parent table.
    When I am deleting a row from parent, message gets displayed as "there are child records found."
    I would like to know, if there is foreign key relatioship then delete trigger on parent does't work, what is exactly happening?

    Could you post that trigger code and the Oracle version as well?
    With basic assumptions, I can't reproduce what you have stated here.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> create table parent (id number primary key);
    Table created.
    SQL> create table child (id number);
    Table created.
    SQL> alter table child add constraint fk_parent foreign key (id) references parent;
    Table altered.
    SQL> create or replace trigger bdr_parent
      2  before delete on parent
      3  for each row
      4  begin
      5  delete from child where id = :old.id;
      6  end;
      7  /
    Trigger created.
    SQL> insert into parent (id) values (1);
    1 row created.
    SQL> insert into child (id) values (1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> delete from parent where id = 1;
    1 row deleted.
    SQL> select * from parent;
    no rows selected
    SQL> select * from child;
    no rows selected
    SQL> rollback;
    Rollback complete.
    SQL> alter table child drop constraint fk_parent;
    Table altered.
    SQL> alter table child add constraint fk_parent foreign key (id) references parent on delete cascade;
    Table altered.
    SQL> delete from parent where id = 1;
    delete from parent where id = 1
    ERROR at line 1:
    ORA-04091: table SCOTT.CHILD is mutating, trigger/function may not see it
    ORA-06512: at "SCOTT.BDR_PARENT", line 2
    ORA-04088: error during execution of trigger 'SCOTT.BDR_PARENT'
    SQL>

  • Few newbie questions before I buy?

    I'm currently in a Moto V3 and am considering the iPhone because of the large, easy to read screen. I'm certainly not old, but due to a cataract, my eyesight isn't what it was. I've looked at most of the SmartPhones out there and quite frankly, I can't read them easily.
    I am concerned that it won't meet my changing business needs, (not that the razr does either) and am wondering if any phone will? So on to my questions:
    1) Is there a limit to the number of contacts? Would 1000 names and addresses fit? Is there a way to make separate directories for personal and business?
    2) I've read there is no way to cut and paste, but is there a way to save e-mail templates?
    3) For work, we use a web based CRM, however in my PC it required the installation of version 1.4.1_02 of the Java Runtime Environment. I've read the the iphone doesn't support Java but is this something different than the Java games? If I could get into our work CRM, through Safari I could use the e-mail templates stored there.
    4) Synching contacts: I use Act! as my contact manager and e-mail client. I don't expect the iPhone to work with that, but I can export the contact I want to sync into either outlook or windows address book. I don't want todos to sync and would prefer the sync to be 'one way' only ie; WCM -> iPhone only. Is this configurable?
    I've been reading this board for some time now, but using the search feature has been frustrating as I can't seem to narrow it down enough to find answers to my specific questions. Thanks for reading my long post, and Merry Christmas!

    It's beginning to seem like that, but sometimes the 'heart overrules the head'. I want one and want to make it work!
    I understand there's no push email, and I don't mind having the phone poll the e-mail box every 30 minutes or so. I also understand that Act won't work with it, heck I'm using Act 2000 (the last stable version) and its not supported much anyway. (I could never get it to work with my messagepad 2000 and Act for Newton)
    Does the phone support multiple e-mail accounts? I could set up a new account just for prospects from the CRM and have the phone automatically poll this account and then manually pull from my main mail account only as needed?
    Finally, and this may sound stupid, but I'm assuming that it only downloads the message headers and let's me decide to bring in the whole message at my discretion?
    Also silly question, but deleting messages from the phone leaves the messages on the server for later download on my PC....right?

  • Trigger mutating and delete tables

    hello
    i have to update 2 tables one is mutating wich i already resolve, the other no and both get the values for a third table , after i update the 2 tables, i have to delete the values of the third one .
    But if i use the instruccion FOLLOWS this dont do anyything and dont delete the values. I cant use the compound triggers because this version of oracle somehow dont work.
    thsi is my code.
    CREATE OR REPLACE PACKAGE PCK_UDA1
    IS
    type arreglo is table of rowid index by binary_integer;
    v_u1acct arreglo;
    v_reset arreglo;
    END;
    CREATE OR REPLACE TRIGGER RESET_UDA1_BU
    BEFORE UPDATE ON UDA1
    BEGIN
    DBMS_OUTPUT.put_line('RESET_UDA1_BU');
    PCK_UDA1.v_u1acct := PCK_UDA1.v_reset;
    END;
    here there are the condition to update the status
    CREATE OR REPLACE TRIGGER UDA1_AU
    AFTER UPDATE ON UDA1 FOR EACH ROW
    BEGIN
    DBMS_OUTPUT.put_line('UDA1_AU');
    IF ((:NEW.U1STATUS = 'VEN' OR :NEW.U1STATUS = 'SAC') AND :OLD.U1STATUS = 'LIQ') THEN
    PCK_UDA1.v_u1acct(PCK_UDA1.v_u1acct.count+1):= :NEW.u1acct;
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN dbms_output.put_line('SIN DATOS');
    WHEN OTHERS THEN dbms_output.put_line(SQLERRM);
    END;
    CREATE OR REPLACE TRIGGER UPDATE_UDA1_FIN2
    AFTER UPDATE ON UDA1
    BEGIN
    DBMS_OUTPUT.put_line('UPDATE_UDA1_FIN2');
    FOR i in 1 .. PCK_UDA1.v_u1acct.count loop
    UPDATE UDa1 set u1calc5= (SELECT u1calc5 FROM GESTION.HIS_FINANCIERA2 where dmacct = PCK_UDA1.v_u1acct(i)),
    WHERE u1acct = PCK_UDA1.v_u1acct(i);
    END LOOP;
    PCK_UDA1.v_u1acct.delete;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN dbms_output.put_line('SIN DATOS');
    WHEN OTHERS THEN dbms_output.put_line(SQLERRM);
    END;
    here i update the values of the other table.CREATE OR REPLACE TRIGGER UPDATE_DLQ_FIN2
    AFTER UPDATE ON UDA1
    FOLLOWS UPDATE_UDA1_FIN2
    BEGIN
    DBMS_OUTPUT.put_line('UPDATE_DLQ_FIN2');
    FOR j in 1 .. PCK_UDA1.v_u1acct.count loop
    UPDATE DELQMST SET DMAMTDLQ =(SELECT DMAMTDLQ FROM GESTION.HIS_FINANCIERA2 where dmacct = PCK_UDA1.v_u1acct(j)),
    DMCURBAL =(SELECT DMCURBAL FROM GESTION.HIS_FINANCIERA2 where dmacct = PCK_UDA1.v_u1acct(j))
    WHERE DMACCT = PCK_UDA1.v_u1acct(j);
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN dbms_output.put_line('SIN DATOS');
    WHEN OTHERS THEN dbms_output.put_line(SQLERRM);
    END;
    HEres is the one that i want to delete the table from i get the values.CREATE OR REPLACE TRIGGER PARENT_DELETE_FIN2
    AFTER UPDATE ON UDA1
    FOLLOWS UPDATE_DLQ_FIN2
    BEGIN
         DBMS_OUTPUT.put_line('PARENT_DELETE_FIN2');
    FOR k in 1 .. PCK_UDA1.v_u1acct.count loop
    DELETE FROM GESTION.HIS_FINANCIERA2 where dmacct = PCK_UDA1.v_u1acct(k);
    end loop;
         EXCEPTION
    WHEN NO_DATA_FOUND THEN dbms_output.put_line('SIN DATOS');
    WHEN OTHERS THEN dbms_output.put_line(SQLERRM);
    END;
    is there a wayr to tell oracle to update first the table the 2 table, and then delete the values of the third one.

    since we don't have your tables or data, we can NOT run, test or improve posted code.
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ
    delete, remove, & eliminate all EXCEPTION code
    For reason why check these links.
    http://tkyte.blogspot.com/2007/03/dreaded-others-then-null-strikes-again.html
    http://tkyte.blogspot.com/2008/01/why-do-people-do-this.html
    http://tkyte.blogspot.com/2007/03/challenge.html

  • How to check if a Site Column is being used before deleting

    Hi All,
    Before deleting a SharePoint Online site column I would like to check to see if it is being used by any list or library. I know how to do this when the site is on
    premise using a PowerShell script.
    $web
    = Get-SPWeb
    http://”sitecollectionurl”
    $column
    = $web.Fields[“Column Display Name”]
    $column.ListsFieldUsedIn()
    but I am having problems doing it on a SharePoint Online site. I know how to connect to the site, but I can not find any information on getting the field details,
    like above.
    if ((Get-ModuleMicrosoft.Online.SharePoint.PowerShell).Count
    -eq0) {
    Import-Module
    Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
    $username
    = "[email protected]"
    $url
    = "https://mySite.sharepoint.com/sites/Dev"
    Write-Host
    "Connecting to SharePoint Online, URL = $url"
    try
    Connect-SPOService
    -Url $url /
    -credential $username
    Write-Host "Successfully connected.."
    -ForegroundColor Green
    $web =
    Get-SPOSite -Identity
    https://mySite.sharepoint.com/sites/Team1
    $column
    = $web.Fields[“Column Display Name”]
    $column.ListsFieldUsedIn()
    =
    $web.Fields[“Page Content”]
    catch
    Write-Error "Failed to connect to
    $url - check the credentials and URL!"
    $_
    Write-Host
    "Disconnecting from SharePoint Online, URL =
    $url"
    Disconnect-SPOService
    Write-Host
    "Successfully disconnected.."
    -ForegroundColor Green
    Does any know what I am doing wrong, or does anyone have a script examples.
    Many thanks
    Colin

    Hi Colin,
    Unfortunately the Get-SPOSite doesn't return a fully fledged SPWeb object like you're used to in On-Prem PowerShell.
    The only way to get at particular objects like this is to use CSOM in PowerShell, however even then it doesn't return quite the same object that you see on prem. (In short, the method you want doesn't exist.. but I'll show you how to get there at least.)
    You'll need the Microsoft.SharePoint.Client.dll installed (You can download the SharePoint 2013 Client SDK, just do a search for it.)
    Once that's installed, then the following script will retrieve a single column which you can then run
    $column | gm to see the available properties.
    $siteCollectionURL = "https://<tenantname>.sharepoint.com/sites/etc"
    $Credentials = Get-Credential -UserName "[email protected]" -Message "Enter the password for $AdminUser"
    ##Then we'll establish a ClientContext for CSOM.
    $scContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteCollectionURL)
    $SPOcredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credentials.UserName, $Credentials.Password)
    $scContext.Credentials = $SPOcredentials
    $web = $scContext.Web
    $siteCols = $web.Fields
    $column = $sitecols.GetByInternalNameOrTitle("ColumnInternalName")
    $scContext.load($web)
    $scContext.load($siteCols)
    $scContext.Load($column)
    $scContext.ExecuteQuery()
    Once you run that, $column contains as much info as you can get about the column.
    Paul.
    Please ensure that you mark a question as Answered once you receive a satisfactory response. This helps people in future when searching and helps prevent the same questions being asked multiple times.

  • 2 Qs PRIMARY Q: Should one compact before deleting TB email or vice versa

    HELLO, MY PRIMARY QUESTION: Apparently compacting is part of deletion. But should one Compact before Deleting TB email or Vice Versa OR does it matter which comes first?
    SECONDARY NOTE & QUESTION;i have read the article on compacting but still do not know exactly what this word means- (e.g. does it means compressing & why is it absolutely necessary for deletion? In this regard the TB compacting article says in PERTINENT part; "IF the message is marked as DELETED or moved, Thunderbird SKIPS that message and moves onto the next message." The preceding quote would seem to say that compacting is not part of deletion, yet i know (or think I know) that both deleting a email and compacting it are necessary for its TOTAL DELETION in TB. Can anyone explain this seeming contradiction? ( I used to use Outlook and i do not remember the term "compacting" with that system).
    ANY ANSWER TO EITHER QUESTION WOULD BE GREATLY APPRECIATED. THANK YOU

    Deleting a message marks it for deletion and hides it. Compacting actually removes it and frees up the disk space. Delete then compact.
    Despite the poorly chosen name compacting has nothing to do with compressing files as in zipping them.

  • Help with a Before Delete Triggger

    Hello:
    When I do a delete operation on a table that has the following trigger, it comes up with an error message,
    ":ORA-04091: table INNOBOX.SUGGEST is mutating, trigger/function may not see it
    ORA-06512: at "INNOBOX.DELSUGGEST", line 44
    ORA-04088: error during execution of trigger 'INNOBOX.DELSUGGEST'"
    Can somebody tell me what I am doing wrong?
    CREATE OR REPLACE TRIGGER INNOBOX.delSuggest
    BEFORE DELETE
    ON INNOBOX.SUGGEST
         FOR EACH ROW
              BEGIN
                   INSERT INTO INNOBOX.SUGGEST_LOG
                        Sugg_Log_ID_N,
                        Sugg_No_N,
                        Cat_CD_C,
                        Liaison_CD_C,
                        S_Desc_C,
                        L_Desc_C,
                        S_Stat_CD_C,
                        S_Stat_DT,
                        Benefit_C,
                        Cost_Sav_C,
                        Resol_C,
                        D_Stat_CD_C,
                        D_Stat_DT,
                        ACD_CD_C,
                             Cr_By_ID_C,
                        Cr_DT,
                        Up_By_ID_C,
                        Up_DT     
                   VALUES
                             INNOBOX.Suggest_Log_Seq.NEXTVAL,
                        :old.Sugg_No_N,
                        :old.Cat_CD_C,
                        :old.Liaison_CD_C,
                        :old.S_Desc_C,
                        :old.L_Desc_C,
                        :old.S_Stat_CD_C,
                        :old.S_Stat_DT,
                        :old.Benefit_C,
                        :old.Cost_Sav_C,
                        :old.Resol_C,
                        :old.D_Stat_CD_C,
                             :old.D_Stat_DT,
                             'D',
                             :old.Cr_By_ID_C,
                             :old.Cr_DT,
                             :old.Up_By_ID_C,
                             :old.Up_DT
                   DELETE SUGGEST WHERE Sugg_No_N = :old.Sugg_No_N
              END;
    Thanks.
    Venki

    Hi,
    Try to remove the last line from your trigger :
    DELETE SUGGEST WHERE Sugg_No_N = :old.Sugg_No_N, you delete a line from a table for which there is the same before delete trigger, also there is a muttating trigger.
    HTH,
    Nicolas.

  • HT5787 i have another account but i can't remember the password and the security question. i deleted my email and i can't change the password with the email because it doesn't exist.

    i

    Hi bertram.thoninh,
    Thanks for visiting Apple Support Communities.
    This article can help with resetting your password and security questions:
    Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/HT5312
    However, if you're not able to receive email to your rescue email address, you may need to contact iTunes Store Support:
    You'll need to contact iTunes Store support to have your questions and answers reset.
    After your password, security questions and answers are reset, I'd recommend providing a different rescue email address:
    You can edit or delete your rescue email address at My Apple ID. To edit your rescue email address:
    Navigate to My Apple ID using your web browser.
    Click "Manage your account"
    When prompted, sign in using your Apple ID and password.
    Click Password & Security
    You'll be asked to answer 2 of your 3 security questions before you can make any modifications. If you are unable to remember your answers, you can choose to send an email to your rescue email to reset your security questions.
    All the best,
    Jeremy

  • Security Trigger Question?

    Hi all,
    I'm trying to create a trigger which will allow only certain users to issue DML statements on a table.
    The users who have access are returned from a sql query.
    The trigger I have created looks like the following,
    CREATE OR REPLACE TRIGGER test          
    BEFORE INSERT OR UPDATE OR DELETE
    ON project
    DECLARE     
    CURSOR user_cur IS
       SELECT e.emp_id
       FROM employee e, org_unit o
       WHERE e.ou_id = o.ou_id
       AND o.ou_name = 'Innovation North';
    v_user NUMBER;
    v_cur_user VARCHAR2(10);
    begin
    OPEN user_cur;
      LOOP
       FETCH user_cur INTO v_user;
       EXIT WHEN user_cur%NOTFOUND;
        SELECT user INTO v_cur_user FROM dual;
        IF v_cur_user <> v_user THEN
         RAISE_APPLICATION_ERROR(-20001, 'User: '|| v_cur_user ||' does not have authority to update this table');
        END IF;
      END LOOP;
    CLOSE user_cur;
    END;
    /I'm pretty sure the trigger works fine, however, for this to work, does each user need this trigger in there own schema's, or is there some way of implementing a system trigger which works for all users?
    I know this problem can be achieved using much simpler techniques but i'm investigating alternative methods.
    Cheers guys!

    I'm pretty sure the trigger works fineWell, as e.emp_id would seem to be number and USER is not allowed to be all numeric it seems to me that this trigger will always fail.
    I know this problem can be achieved using much simpler techniques What I think you are groping towards implementing is Row Level Security (aka Virtual Private Database). This works well in Oracle from 8.1.7 onwards.
    If you don't want to use RLS (or don't want to pay for the enterprise edition) I suggest you start looking at using views. This trigger-based approach is really a bad idea, being both inflexible, slow and excessively punitive towards the users.
    Cheers, APC

  • Trigger events when delete/modify certain folder in KM

    Dear Experts,
    I have a requirement like when certain folder is being deleted/modified I want an event need to be trigger, such that I will put some checks before these commands performed.
    Basically my requirement is, I have a custom iViews created and are using custom tables in databse.  When I create the folders in KM, I am creating/maintaining these folder reference in my custom tablese using my custom iView.
    Now when I delete the folder from KM, I want to show some warning message before deleting the folder and simulatenously these folder references should also be deleted from my custom tables.
    Please give me suggestions how to acheive the above scenario.
    Thanks in Advance,
    Chinna.

    Hi Yogalakshmi,
    I have created a Repository service using the document provided. I have registered the pre_delete_template  event using the below code         
    unregister(this,ResourceEvent.PRE_DELETE_TEMPLATE);
    I am printing some trace when this event occurs. Logs is being displayed after the folder gets deleted.
    Can you please provide me some code snippet for register predelete event, and on attempting to delete I would like to pop up a window with warning/confirmation message (confirmation popup window). Based on the confirmation from the popup window -- Ok/Cancel, I would like to perform few operations.
    I don't find any documents on Repository Services.
    Could you please provide me code/documents that fulfills my requirement.
    Thanks
    Chinna.

Maybe you are looking for

  • Apple Match-O Linker Error

    I am making a menu bar app and it is going fine and all but I get an error saying "clang: error: linker command failed with exit code 1 (use -v to see invocation)" here it is in more detail: duplicate symbol _OBJC_METACLASS_$_View in:     /Users/Tom/

  • Problem Transfering Photos from PC to iPhone 4 with version 5.1.1

    I can't transfer multiple Folders containing photos from my PC to my iPhone.  My digital photos on my PC are simply in Folders as JPEG files.  When I try to transfer the Folders in iTunes I can only select the "All Folders" option.  The "Selected Fol

  • Error when installing Incredibles game on Snow Leopard

    Have the Incredibles game for the kids... Trying to install on the new iMac 27 incher... Getting the following error/message. Initializing InstallShield Wizard... Searching for Java(tm) Virtual Machine... ..........A suitable JVM could not be found.

  • I'am newer

    when i connect as hr/hr@orcl an error msg appear saying "TNS:listener does not currently know of service requested in connect descriptor" what i can do

  • Background image not displaying 100% width of iphone

    Hi I am getting some strange behaviour on my iphone using firefox but displaying perfectly in firefox on computer.  I do not wish to submit the name of site as I do not want it to show up in search results but if anyone can help me I will pm site add