Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting USER that made an insert query with a trigger

4143087Nov 30 2019 — edited Nov 30 2019

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

Comments

Frank Kulash

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

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

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

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

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 Thorton

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?


1 - 6

Post Details

Added on Nov 30 2019
6 comments
585 views