Forum Stats

  • 3,839,949 Users
  • 2,262,551 Discussions
  • 7,901,101 Comments

Discussions

Getting USER that made an insert query with a trigger

4143087
4143087 Member Posts: 2
edited Nov 30, 2019 11:17PM in SQL & PL/SQL

so i have trigger that fires before an insert quuery , how can i get the USER that made the insert query ?

Tagged:
John ThortonFrank Kulash

Answers

  • Frank Kulash
    Frank Kulash Member, Moderator Posts: 42,265 Red Diamond
    edited Nov 30, 2019 4:10PM

    Hi,

    4143087 wrote:so i have trigger that fires before an insert quuery , how can i get the USER that made the insert query ?

    The USER function returns the Oracle user name.

    Some applications manage their own users: everyone connects using a generic Oracle user, then authenticates in some application-specific way.  If you're application is like that, then ask someone familiar with your application.

  • John Thorton
    John Thorton Member Posts: 14,493 Silver Crown
    edited Nov 30, 2019 4:10PM
    4143087 wrote:so i have trigger that fires before an insert quuery , how can i get the USER that made the insert query ?

    What exactly do you desire to obtain?

    Is your application implemented like below?

    EndUser<=>browser<=>webserver<=>ApplicationServer<=>DatabaseServer

  • 4143087
    4143087 Member Posts: 2
    edited Nov 30, 2019 5:14PM

    no , i have homework in pl/sql :

    i have these tables :

    -- OUVRAGE(IDO,TITRE,ANNEE,THEME,LIKES,DISLIKES)

    -- COPIE(IDC,ETAT,IDO#)

    -- ETUDIANT(IDE,CIN,NOM,CURSUS)

    -- PRET(IDC#,IDE#,DATEP,DATER,AVIS,IDB#)

    -- BIBLIO(IDB,NOM)

    I have 3 users

    so it asks to create a trigger that launchs before an insert query in the table PRET  , the trigger should update ETAT in table PRET and also to read the name of user who made that insert query ..

  • EdStevens
    EdStevens Member Posts: 28,778 Gold Crown
    edited Nov 30, 2019 7:02PM
    4143087 wrote:no , i have homework in pl/sql :i have these tables : -- OUVRAGE(IDO,TITRE,ANNEE,THEME,LIKES,DISLIKES)-- COPIE(IDC,ETAT,IDO#)-- ETUDIANT(IDE,CIN,NOM,CURSUS)-- PRET(IDC#,IDE#,DATEP,DATER,AVIS,IDB#)-- BIBLIO(IDB,NOM)I have 3 users so it asks to create a trigger that launchs before an insert query in the table PRET , the trigger should update ETAT in table PRET and also to read the name of user who made that insert query ..

    YOu should have stated up front that it was a homework assignment. 

    So, being a homework, we can ignore the fact that the specific use of the trigger might very well be worthless in a real production enviornment (take note for when you ARE working in a real production environment) and focus on the technique.

    And, being homework, we would very much expect to see what you've tried for yourself and your explanation of what is wrong with what you have so far. You gain nothing by having someone else do your homework for you.

  • Mike Kutz
    Mike Kutz Member Posts: 6,198 Silver Crown
    edited Nov 30, 2019 7:06PM

    Homework questions are not a problem.  However,  we do require you to post what you have tried

    If you need a database to use to test on, http://LiveSQL.oracle.com would be one you can access through a web browser (and only a web browser)

    ------

    I suggest you start with an example code and modify it to fit your needs.

    The Fine Manual would be a good place to start.

    Forgive me for posting the link to v7 when v20 will be out soon.

    https://docs.oracle.com/cd/A57673_01/DOC/dcommon/oin/index.htm

    I doubt the syntax has changed much.

    MK

    John ThortonFrank Kulash
  • John Thorton
    John Thorton Member Posts: 14,493 Silver Crown
    edited Nov 30, 2019 11:17PM
    4143087 wrote:no , i have homework in pl/sql :i have these tables : -- OUVRAGE(IDO,TITRE,ANNEE,THEME,LIKES,DISLIKES)-- COPIE(IDC,ETAT,IDO#)-- ETUDIANT(IDE,CIN,NOM,CURSUS)-- PRET(IDC#,IDE#,DATEP,DATER,AVIS,IDB#)-- BIBLIO(IDB,NOM)I have 3 users so it asks to create a trigger that launchs before an insert query in the table PRET , the trigger should update ETAT in table PRET and also to read the name of user who made that insert query ..

    Please NOTE that the PRET table does NOT contain any ETAT column; so either wrong table or wrong column.

    But some is WRONG with the requirements statement.

    Along this line, please clarify into which table & column the USER name needs to be INSERTED

    Please click on URL below & provide details as stated in #5 - #9 inclusive

    How do I ask a question on the forums?