can anyone help me with this one!
I would like to have a trigger in Oracle, which finds out the user's Windows logon name.
The user name should be added in to table "Product" (column "username"), after insertion of other data in the table "Product".
Thanks in advance for any help you are able to provide.
How to make one trigger that operates on all tables? Otherwise, I got a lot of triggers in the database.In SQL Developer can be selected only one table. I wish one trigger that takes username information and add's it to that table I insert data at that moment.
Related
I have a table in Oracle with some columns that needs to be audited.For every new insert into a table/for every update of the Table, I need to put an entry in audit table for each column inserted/Updated/Deleted.For every update ,suppose I update 1st 2nd column ,then it will create two record in audit with its old value and new value.
But I need to do it without using a trigger, is there any other way to do it?
Could anyone please help me with this.
Many thanks in advance.
Using trigger-based auditing is the best solution for this. Not sure, why you are trying to do without a trigger.
I think you can use the DBMS_FGA for your requirements.
But there will be no Old and new Values.
You can have a record for every column if you make several FGAs in the same table, one for each columns of interest
regards
Altin
I get the a query file and commit it but I have to choose the schema before it, to not get the following error; do you have any idea how to do it?
Thanks for your interest.
INSERT INTO LEAD_ACTV_CONFIG (
*
ERROR at line 1:
ORA-00942: table or view does not exist
I don't know jenkins so I hope the following makes sense. Sorry if it does not.
In order for INSERT to work, you must be connected to a database (i.e. one of its users). That user should contain LEAD_ACTV_CONFIG table, or it must be available to it (which means that some other user, who owns it, has granted the current user access privileges).
Now, if LEAD_ACTV_CONFIG is your own table, then your INSERT INTO would work properly; you don't need any additional privileges as you own the table so you can do anything with it.
If it is someone else's table, then either precede table name with owner name, such as INSERT INTO littlefoot.lead_actv_config (as if I own it), or create a synonym for that table in your schema:
create synonym lead_actv_config for littlefoot.lead_actv_config;
and access it just as you've posted in your question: insert into lead_actv_config
was wondering if anyone had any insight on creating an audit trail process in VB6?
I have an application that gets populated with existing data with the use of 3 or 4 classes. The user can then modify any data they wish on this application. Then the data is saved into tables used for a queue. Basically exact copies of the tables the data came from. My problem is I need to create an audit trail.
What is the best practice for this? Compare every control (text box, radio, check box) on the application which is around 100? Or can I utilize the text_changed event of the text boxes? Really have no idea where to start on this one.
Oh and to make it fun, using a Pervasive DB v9.
Thanks for any help.
Cheers
This should always be done inside the DB.
Something like this (cribbed in part from post to the pervasive forum, I haven't actually used Pervasive):
create trigger insTrig
before insert on table1
referencing new as new_rec
for each row
insert into table2 values (new_rec.co1,new_rec.col2,new_rec.col3,...)#
create trigger delTrig
before delete on table1
referencing old as new_rec
for each row
insert into table2 values (new_rec.co1,new_rec.col2,new_rec.col3,...)#
create trigger updTrig
after update on table1
referencing new as new_rec
for each row
insert into table2 values (new_rec.co1,new_rec.col2,new_rec.col3,...)#
I currently have 2 schemas, A and B.
B has a table, and A executes selects inserts and updates on it.
In our sql scripts, we have granted permissions to A so it can complete its tasks.
grant select on B.thetable to A
etc,etc
Now, table 'thetable' is dropped and another table is renamed to B at least once a day.
rename someothertable to thetable
After doing this, we get an error when A executes a select on B.thetable.
ORA-00942: table or view does not exist
Is it possible that after executing the drop + rename operations, grants are lost as well?
Do we have to assign permissions once again ?
update
someothertable has no grants.
update2
The daily process that inserts data into 'thetable' executes a commit every N insertions, so were not able to execute any rollback. That's why we use 2 tables.
Thanks in advance
Yes, once you drop the table, the grant is also dropped.
You could try to create a VIEW selecting from thetable and granting SELECT on that.
Your strategy of dropping a table regularly does not sound quite right to me though. Why do you have to do this?
EDIT
There are better ways than dropping the table every day.
Add another column to thetable that states if the row is valid.
Put an index on that column (or extend your existing index that you use to select from that table).
Add another condition to your queries to only consider "valid" rows or create a view to handle that.
When importing data, set the new rows to "new". Once the import is done, you can delete all "valid" rows and set the "new" rows to "valid" in a single transaction.
If the import fails, you can just rollback your transaction.
Perhaps the process that renames the table should also execute a procedure that does your grants for you? You could even get fancy and query the dictionary for existing grants and apply those to the renamed table.
No :
"Oracle Database automatically transfers integrity constraints, indexes, and grants on the old object to the new object."
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9019.htm#SQLRF01608
You must have another problem
Another approach would be to use a temporary table for the work you're doing. After all, it sounds like it is just the data is transitory, at least in that table, and you wouldn't keep having to reapply the grants each time you had a new set of data/create the new table
I'm using (have to) a badly designed Oracle(10) DB, for which I don't have admin rights (although I can create tables, triggers, etc in my scheme).
Now I had run into a problem: this DB connected with several users/programs. I must find out who updates a certain row, when, and if possible: with what kind of statement. Is it possible?
Thanks in advance!
It would be easier to do this if you had admin rights to enable auditing. Without the power of auditing you are left with the use of triggers to handle the logging of inserts/updates/delete. In your case since you are interested in only update, you can put a trigger on the table to fire after the update which logs to another table what was changed, by whom, from where and to what and on what day.
I would create a journal table for the table you are working with. It will show you the operation type and the oracle user...as well as a bunch of other data if you need it.