Trigger code to get user and sysdate

hi all
I am a beginer in sql. I am writing a trigger to get the value of the sysdate and user to be inserted in my table in the following
fields
created_date
update_date
created_by
updated_by
my code is as follows:
Please advice me what is wrong and how i can correct it
BEGIN
IF INSERTING THEN
INSERT INTO MI_AGENT_COMMISSION_TYPE
VALUES (CREATED_DATE, CREATED_BY,:USER, :SYSDATE);
ELSIF UPDATING THEN
INSERT INTO MI_AGENT_COMMISSION_TYPE
VALUES (UPDATED_DATE, UPDATED_BY,:USER, :SYSDATE);
END IF;
END IF;
end;

ELSIF is correct.
The correct syntax is:
CREATE OR REPLACE TRIGGER tr_MI_AGENT_COMMISSION_TYPE
before update or insert on MI_AGENT_COMMISSION_TYPE
for each row
BEGIN
IF INSERTING THEN
:new.CREATED_DATE := sysdate;
:new.CREATED_BY := user;
ELSIF UPDATING THEN
:new.UPDATED_DATE := sysdate;
:new.UPDATED_BY := user;
END IF;
end;

Similar Messages

  • Get user and user-roles in form based authentication

    How do I get user and roles associated with the user in my bean for "form based authentication".
    regards,
    nirvan.

    HttpServletRequest#getUserPrincipal().
    This has nothing to do with JSF. Form based authentication is part of Servlet spec.
    In JSF you can get the HttpServletRequest by ExternalContext#getRequest().

  • Macbook Pro 15 Change Country Code to get 11n and 300 Mbit/s

    Hello All!
    I have a question: how can I change Country Code on my MBP 15" to get wi-fi 11n mode and 300 Mbit/s (or at least 130) with my TL-WR1043ND router. I've changed the Region setting in the web interface of my router, but it didn't solve the problem. And there is a wonder but my macbook 13" has Country Code: X2 (sometimes FR) and use 11n mode with transmit rate: 130 Mbit/s. So, as for me, that is very strange dependence — Country Code and Connection Speed.
    System info:
    Router preferences:
    Thanx!

    So, I have MBP 15-inch, Mid 2010 and MB 13-inch, Mid 2009. And, as I said before, MB 13 doesn't have the problem with 11g mode, it has Contry Code X2 or sometimes FR, but never UA. And the MB13 is older then the MBP15. Maybe problem is in the router, but I don't know how figure out it. And I don't understand, at all, the dependence Transfer Rate and Country Code — why software is restrict connection speed of hardware?

  • Get user and Oranization Attributes  from portal channels

    Hello,
    I am trayin to retrieve some user and arganizational attributes from portal channels (2005Q1), but, with directive "<dtpc:getStringAttribute key="attribute"/>, i can not retrieve some importants attributes as "dn" and an custom attribute from the organization that contain user entry, for example, "orgIdSuscriptor".
    i don't know how to retrieve in the same channel some attributes of user entry and some attributes from oraganization entry, any one know how?
    Thank yu very much.

    Thanks that helpful in some ways, but I want to get the page_id. For example, if I create a page with the name PG_DEPT and the display name "Department Page". I need to know how to get the current PG_DEPT name from the API. Also, I will like to get the current URL from the page (http://portal/pls/portal/page=123).

  • Function module to get user AND usergroup

    Hi Folks,
    I need a function module which returns the user and the usergroup.
    BAPI_USER_GETLIST won't work as it doesn't return the usergroup.
    There are some other function modules but none of them can be called remotely.
    I can't write a function module myself as we are working with validated systems.
    The whole approval process would take months...
    Does anybody know a function module which returns the user AND the usergroup AND can be called remotely?
    Hope somebody can help me.
    Bastian

    are you talking about usr02-CLASS values if yes
    BAPI_USER_GET_DETAIL returns this in
    export parameter LOGONDATA-class
    Regards
    Raja

  • Trigger how to get new and old value for nested table column?

    Hi,
    I have created a nested table based on the following details:
    CREATE TYPE typ_item AS OBJECT --create object
    (prodid NUMBER(5),
    price NUMBER(7,2) )
    CREATE TYPE typ_item_nst -- define nested table type
    AS TABLE OF typ_item
    CREATE TABLE pOrder ( -- create database table
    ordid NUMBER(5),
    supplier NUMBER(5),
    requester NUMBER(4),
    ordered DATE,
    items typ_item_nst)
    NESTED TABLE items STORE AS item_stor_tab
    INSERT INTO pOrder
    VALUES (800, 80, 8000, sysdate,
    typ_item_nst (typ_item (88, 888)));
    Now I would like to create a trigger on table pOrder for after insert or update or delete
    and I would like to track the new and old value for the columns inside nested table.
    Can anybody direct me how to do it?
    I would like to know the sytax for it like:
    declare
    x number;
    begin
    x := :new.nestedtablecolumn;--how to get the new and old value from nested table columns
    end;
    Hope my question is clear.
    Thanks,
    Lavan

    Hi,
    Try like this:
    CREATE OR REPLACE TRIGGER PORDER_I
    BEFORE INSERT
    ON PORDER
    REFERENCING OLD AS old NEW AS new
    FOR EACH ROW
    DECLARE
      items_new typ_item_nst;
      ordid_NEW NUMBER;
    BEGIN
    FOR i IN :new.items.FIRST .. :new.items.LAST LOOP -- For first to last element
      DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').prodid: ' || :new.items(I).prodid );
      DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').price:  ' || :new.items(I).price );
    END LOOP;
    END;Regards,
    Peter

  • Java code to get user mapping info

    I am writing a Java Servlet that needs to read the username and password to a user mapping system.  Can anyone post a code example that will accomplish this?  I have already been looking through the forums, so please don't post links to other forum entries.

    hello Pfister,
       I'll send you one article link , just go thru it ,
    you can many examples from basics. if you get any errors just take that error no. which displayed , you can find the solution for that error in the link.
    This link you can see one good example:
    http://www.onjava.com/pub/a/onjava/excerpt/java_cookbook_ch18/index.html?page=5
    Regards,
    Varun

  • How to get user and system status for a trade promotion

    Hi,
    I have to develop a batch program to change user status and system status of all trade promotions which satisfy some criteria. This criteria checks some dates related to trade promotion(like Changed on,Pallett buying, buying horizon dates) also.
    I thought of first extracting all external ids from CGPL_PROJECTS table and then run trade promotion query. But how can I get current user & system status and all dates as these can be taken from relations "TPMStatusActiveRel" and "TPMDateRel". I don't know to take data from relations. Please help me with a piece of code.
    Thanks.

    Hello Shikha,
    You can use these relations here, as you are not in the Business Object layer anymore. As far as my understanding is, all the batch programs or reports should be done at the API layer. Try this code, to read the status of the Trade Promotion object.
    data: lr_appl_base type ref to CL_CRM_MKTPL_APPL_BASE,
            lt_sys_status type CGPL_ISTATUS_TEXT_T.
    lr_appl_base ?= CL_CRM_MKTPL_APPL_BASE=>GET_INSTANCE().
    " To read system status
    call method lr_appl_base->STATUS_READ
    exporting
    IM_MKTELEMENT_GUID = "your Trade promotion guid
    ET_TJ02T  = lt_sys_status.
    " To read user status
    call method lr_appl_base->STATUS_READ_EXTERN
    exporting
    IM_MKTELEMENT_GUID = "your Trade promotion guid
    ET_TJ02T  = lt_sys_status1.
    To change the user status, use the method STATUS_CHANGE_EXTERN of the same class
    To set the system status, use the method STATUS_SET of the same class.
    Hope this helps.
    Regards,
    Vinay

  • Get User Names and Mail Ids present in Exchange Server

    Hello All,
    Can we get all the names and mail ids present in the exchange Server global address book?
    I tried one example but it is giving error.
    Exception in thread "main" javax.naming.CommunicationException: [LDAP: error
                code 2 - Protocol Error]; remaining name 's=satheesh'
    Code is given below:
    Hashtable env = new Hashtable(11);
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://mailserver:389");
    DirContext ctx = new InitialDirContext(env);
    Attributes answer = ctx.getAttributes("s=satheesh");
    Any example code to get user names and mail ids will be helpful.
    Thanks in advance.
    Regards,
    Satheesh A
    [email protected]

    Hi Satheesh,
    I am new to LDAP. I am facing the exact same problem as you mentioned. Did you solve your problem?
    Thanks for any help you can provide.
    Hello All,
    Can we get all the names and mail ids present in the
    exchange Server global address book?
    I tried one example but it is giving error.
    Exception in thread "main"
    read "main" javax.naming.CommunicationException:
    [LDAP: error
    code 2 - Protocol Error]; remaining name
    aining name 's=satheesh'
    Code is given below:
    Hashtable env = new Hashtable(11);
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL,
    "ldap://mailserver:389");
    DirContext ctx = new InitialDirContext(env);
    Attributes answer = ctx.getAttributes("s=satheesh");
    Any example code to get user names and mail ids will
    be helpful.
    Thanks in advance.
    Regards,
    Satheesh A
    [email protected]

  • How to Get user profile properties in provider -cloud hosted app in sharepoint online - office 365 using REST API?

    How to Get user profile properties in provider -cloud hosted app in sharepoint online - office 365 using REST API?
    any idea?

    Hi,
    From your description, my understanding is that you want to get user profile properties in provider-hosted app in SharePoint online using REST API.
    Here is sample code for getting user profile properties:
    http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html
    Here is a blog below about accessing data from the provider-host apps:
    http://dannyjessee.com/blog/index.php/2014/07/accessing-sharepoint-data-from-provider-hosted-apps-use-the-right-context/
    Best Regards,
    Vincent Han
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Getting users permissions

    Hello
    I would like to access all permissions for all the users and then display it in a grid (or matrix).
    Users should be displayed as columns and permissions for a particular users as rows.
    I should be able to colapse and expand permissions trees.
    What should I use to achieve my goal? What kind of objects?
    Thanks in advance
    Kamil
    I used SBObob object to get users and I'm thinking about using GetSystemPermission method but I have to provide permission id.
    Where can I find all permisson ids? Or is there other way to achive my goal?
    Is this possible at all?
    I want to achieve something similar to what can be seen at administration -> authorizations -> general authorizations
    but I want users as columns and particular authorizations as rows
    Edited by: Kamil Wydrzycki on Oct 13, 2009 11:51 AM

    It's not pretty but here is what I've come up with by cobbling together various snippets. It will go through all mailboxes and dump the folder permissions for each user and create a txt file for each user for the user's review. You can manipulate the output
    anyway you want. I'm not filtering the results so the script console has a lot of errors for folders like "Top of Information Store, Recoverable Items, Deletions, Purges, Versions"
    Note: I'm not a coder by any means... just a jack of all trades system admin so the powershell code is poor.
    #add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
    $reportname=".txt"
    $date=Get-Date
    Write-Output "Recipient Inbox Permissions - Created $date" `n`n | Out-File -Append "$alias$reportname"
    $recipients=Get-Mailbox
    foreach ($recipient in $recipients) {
    $alias=$recipient.alias
    Write-Output $recipient.name $alias | Out-File -Append "$alias$reportname"
    $folders=Get-MailboxFolderStatistics -Identity $alias | % {$_.folderpath} | % {$_.replace(“/”,”\”)}
    foreach ($folder in $folders) {
    $folderpath=":$folder"
    Get-MailBoxFolderPermission -Identity $alias$folderpath | Format-List -Property FolderName,User,AccessRights | Out-File -Append "$alias$reportname"

  • HT1349 Win 7 64 bit:  iTunes won't install, get error code 2324 or installer says I am not logged on as administrator:  only one user and it is an administrator user.

    Win 7 64 bit:  iTunes won't install, get error code 2324 or installer says I am not logged on as administrator:  only one user and it is an administrator user.

    Hey there k8ei,
    Thank you for using Apple Support Communities
    I found this article for you to help troubleshoot installing iTunes named Trouble installing iTunes or QuickTime for Windows found here http://support.apple.com/kb/HT1926.
    Here is a general overview on where the troubleshooting will take you:
    General installation troubleshooting
    1. Empty your Temp directory and restart
    2. Completely remove iTunes and related components
    3. Install the latest version of iTunes
    Additional troubleshooting
    After performing each of the steps below, you will need to completely remove iTunes and related components and then install iTunes again to determine whether the issue is resolved.
    1. Make sure you have administrator account access
    2. Make sure your folder names don't contain strange characters
    3. Get the latest Windows updates
    4. Disable other conflicting software
    All the very best,
    Sterling

  • How to get user ID and password in ADF using code?

    Hi,
    I am using JDev 10.1.3.3 with BC. Security is in OID (user and password) / JAZN.
    I am able to get the user ID, using getUserPrincipalName(),
    but how to get the password?
    I need to pass in a connection string to the Oracle Report Server to run a Oracle report.
    Thanks,
    Jim

    You can get the password by attributeBindings.getterMethodforPassword() where getter Method for Password field is created in your backing bean.
    But there is no defined method like getUserPrincipalName() for getting Password.

  • Help Importing objects from 1 user to another user and problem with trigger

    Hello community, i am having a little difficulty with the exporting objects from one user to another specifically the exporting of the trigger.
    Here is the situation, because of SOX purpose whenever a update is sent to the client the dba have to execute the script as himself (priviliged user) and is not allowed to log into the schema to make changes. Therefore we perpend the object definitions with &user_schema.. and they define user_schema in sqlplus and execute the update script.
    Here is a small example which requires two users (user1 and user2) with the following grants (connect, create table, create trigger, create view, create sequence). Please forgive the naming of the objects, just trying to be as simple as possible.
    I start out by logging in as system user via sqlplus and execute the following.
    ------------------Begin sqlplus----------------------
    define user_schema=user1;
    create table &user_schema..abc01 (
      col1 number,
      col2 varchar2(20),
      col3 number,
      constraint pk_abc01_col1 primary key (col1)
    create table &user_schema..xyz01 (
      col1 number,
      col2 varchar2(20),
      col3 number,
      constraint pk_xyz01_col1 primary key (col1)
    create or replace view &user_schema..view1 as
    select x.col1, x.col2, x.col3, a.col1 as acol1, a.col2 as acol2, a.col3 as acol3
    from xyz01 x
    inner join abc01 a on a.col1 = x.col1;
    create sequence &user_schema..seq_xyz01 start with 1 increment by 1;
    create or replace trigger &user_schema..trig01
    before insert on &user_schema..xyz01 for each row
    begin
      if (nvl(:new.col1, -1) = -1) then
        select seq_xyz01.nextval into :new.col1 from dual;
      end if;
    end;
    /--------------------End sqlplus----------------------
    I would then proceed to export using the exp utility via the command line
    exp system/systempassword file=user1.dmp owner=user1
    Then import user1 objects into user2
    imp system/systempassword file=user1.dmp fromuser=user1 touser=user2
    Now the problem:
    When i take a look at the sql for user2 trigger (trig01) i see the following (viewed via sqldeveloper)
    create or replace TRIGGER "USER2".trig01
    before insert on user1.xyz01 for each row
    begin
      if (nvl(:new.col1, -1) = -1) then
        select seq_xyz01.nextval into :new.col1 from dual;
      end if;
    end;its referring to user1.xyz01 table, however i want it to point to is user2.xyz01 table. Can someone please help me out or offer another solution to go about this because i need the ability to import the objects into a different user without the import failing and having to recompile the object.
    I've also tried executing this while connected as system user via sqlplus:
    define user_schema=user1
    create or replace trigger &user_schema..trig01
    before insert on xyz01 for each row
    begin
      if (nvl(:new.col1, -1) = -1) then
        select seq_xyz01.nextval into :new.col1 from dual;
      end if;
    end;
    /but that fails stating that table or view does not exist, please help
    however that fails because i
    Edited by: user3868150 on Nov 6, 2009 6:05 PM

    When performing an update in their system, the same script will be run with different values, thats not the problem.
    The client currently have just that one schema in their environment, however they want to have another instance of the application set up in their environment (same database) and have that go off on its own track separate from the original application.
    Now when we do an exp of the schema and the imp it into another user it get imported, however its incorrect. As stated before the trigger will be acting on the table in the original schema when it should be acting on the table in the newly imported schema.
    I suppose there is no other way around this when a trigger is created the way in which i outlined above. I guess after the data gets imported into a different user the trigger would have to be recompiled to point to the correct table.
    If you have an alternate solution to go about this i am open to suggestions. However like i mentioned in the original post because of SOX purpose the dba is not allowed to log in and execute update scripts as the schema user. The scripts should only be executed as that privileged user (dba).
    Also if i hard code the user when the trigger is created
    create or replace trigger user1.trig01
    before insert on user1.xyz01 for each row
    begin
    if (nvl(:new.col1, -1) = -1) then
    select seq_xyz01.nextval into :new.col1 from dual;
    end if;
    end;
    /it still doesn't get imported the way that i want it to be imported in user2
    create or replace TRIGGER "USER2".trig01
    before insert on user1.xyz01 for each row
    begin
      if (nvl(:new.col1, -1) = -1) then
        select seq_xyz01.nextval into :new.col1 from dual;
      end if;
    end;now when i do an insert to test
    insert into user1.xyz01 (col2, col3) values ('abc', 123); -- Works fine, no problems here
    insert into user2.xyz01 (col2, col3) values ('abc', 123);Results in an error ORA-01400: cannot insert NULL into ("USER2".XYZ01"."COL1") because the trigger doesn't exist on user2.xyz01 table.
    Just try and create the schema like how i outlined above in your environment to see what i'm talking about. It seems that the only way to get the trigger to be imported the way i want it to is to actually log in as that user and create the trigger.
    sqlplus user1/user1
    {code}
    create or replace trigger trig01
    before insert on xyz01 for each row
    begin
    if (nvl(:new.col1, -1) = -1) then
    select seq_xyz01.nextval into :new.col1 from dual;
    end if;
    end;
    {code}
    Edited by: user3868150 on Nov 6, 2009 6:10 PM

  • How to Create a trigger code for turning on light bulbs in flash and animate images professional cs6

    hi,
        i designed a very interactive music website in illustrator and photoshop and i am trying to animate the main page design in flash professional and eventually publish it as HTML5. There are couple of questions i need to ask before starting
    1) should i import my design in differnet layers from illustrator into flash professional in order to make it easier to isolate and animate specific parts of the web page?
    2) i want to have a roll over effect that allows certain features in the page to turn on and off when the mouse hovers over them. can you explain how to do that? any tutorial videos i could follow
    3) what format should i use when importing my illustrator design into flash professional
    4) how should i animate the content pop out from the safe box into the main screen in flash professional (i have never used this program before, so i will be going off video tutorials and whatever suggestions/help you would have)
    **The idea is to have a content frame fly out of the safe into the screen (the size will increase rapidly and it will fade into the screen as well while rotating 360 degrees for one revolution). The content is a basic rectangular frame i designed in illustrator. The body of this frame will be transparent allowing me to embed the main page features into it eg music, videos, bio etc. All this will be done in the later process, the main issue is figuring out how to animate the content frame into the screen and also creating a click feature that allows the content to fly back into the safe and then the safe closing in.
    Secondly, the trigger code rollover effect that allows certain features light to turn on when the mouse hovers over it and turn over when its not.****

    I think you'll get most flexibility by turning on the feature that lets you keep your Illustrator layers as Flash layers. You'll also want to check the box that lets you make an Illustrator object into a MovieClip for anything that you want to interact with or address through code.
    Add an event listener for MOUSE_OVER that triggers whatever functions you need to create to turn on the features. This means that your object that you will mouse over will need to be a MC, as well as any other objects that will be addressed (for example, calling play()) will need to be a MC. You'll want to have a matching MOUSE_OUT handler that stops MC's, hides them, or whatever.
    You should probably organize your Illustrator file so that the objects you need to address are on their own layers. This includes nested objects. Name things informatively. Remember, if the first import doesn't give you exactly what you want, you don't have to save the change--you can edit your settings or the Illustrator file and try again.
    Look into motion tweens. I highly recommend the books "How to Cheat at Flash" and "Animation with Scripting." I don't really think the way they tell you to script will advance your career if you want to be a software architect, but if you just want to animate the occasional widget, it's fine.

Maybe you are looking for

  • Trying to understand compareTo()

    Hello again world. Please excuse my thickness. I have two issues with the compareTo() method which I think are unrelated. I have an array of "Employee" objects. The array is called "emp" which I sort in main]/b] with the call [b]Arrays.sort(emp) and

  • I want to apple store in my ciy

    hello sir/ma'am,                      i Kpail Ganwani want to open apple store in my city ajmer (rajasthan)                      please tell me the procedure to go through

  • On time payment straight to 60 day late.

    Question for everyone out there. I have a few student loans that I fell behind on several years ago.(they've been current for 3 years now) They all list me as being on time with my payments and then suddenly list a 60 day late. Do you think this is s

  • Problems to load interpretations in Dreamweaver cs 5.5.

    Hi, i am using  Dreamweaver CS 5.5 to design websites but suddenly i got a problem when opening files. It says: Following interpretation was not loaded because of errors: ASP.htm: contains invalid configuration information. ColdFusion.htm: contains i

  • Game output from iPad 2 to HDTV

    Can I output any Game app from my iPad 2 to my HDTV or just specially designed games?