How to convert update,delete statement into select stmt
Hi all,
I have a field called dml_stmt, i am getting the dml statement has input from the user.
My requirement is, if user is giving "update set col_name = 'xyz' from table_name where codition = 'aa'", before updating the table, i need to get old values from the table and put it in the audit table
For that,i need to convert those update statement into select stmt and need to execute the query to get the data and then i will put it in the audit table..
can anyone guide how to convert the update or delete stmt into select(need to write in pl/sql)
Please do needfull things ......
Regards,
Jame
Maybe I'm missing something, but why would auditing help here? It sounds like the user wants to know the prior values of the data, not the SQL UPDATE statement that was issued. Auditing would tell you that a table was updated, fine-grained auditing would tell you what the UPDATE statement was, but you'd need something else to capture the state of the data prior to the update.
Depending on why putting triggers on every table was discounted, you may also want to take a look at using Workspace Manager or Total Recall (in 11g) to track a history of data changes. But triggers would be the common solution to this sort of problem.
Justin
Similar Messages
-
Converting a delete statement using VPD policies and context
Hello,
I'm trying to convert a delete statement in a update statement using VPD policies and context.
+/* Supose the user 'user1' already exists. This is an application user */+
conn user1/pwd
create table user1.test_a (
id number(4),
description varchar2(100),
deleted number(1)
+);+
alter table user1.test_a add constraint test_a_pk primary key (id);
insert into user1.test_a (1, 'abc', 0);
insert into user1.test_a (2, 'def', 0);
commit;
I'd like to convert each physical deletion into a logical deletion: statements like "delete from user1.test_a where id = 1" must be converted into "update user1.test_a set deleted = 1 where id = 1".
I've found the following way: I will create a policy to avoid physical deletion. Additionally, the policy function should update the deletion flag too.
conn user1/pwd
+/* Create context package */+
create or replace package user1.pkg_security_context is
procedure p_set_ctx(
i_test_a_id in user1.test_a.id %type
+);+
end;
+/+
create or replace package body user1.pkg_security_context is
procedure p_set_ctx (
i_test_a_id in user1.test_a.id %type
+) is+
begin
dbms_session.set_context( 'user1_ctx', 'test_a_id', i_test_a_id );
end;
end;
+/+
show errors
+/* Create trigger to set the context before deletion */+
create or replace trigger user1.test_a_bef_trg
before delete on user1.test_a
for each row
declare
pragma autonomous_transaction;
begin
-- only commits the preceding update, not the delete that fired the trigger.
commit;
user1.pkg_security_context.p_set_ctx( :old.id );
end;
+/+
show errors
create context user1_ctx using user1.pkg_security_context;
+/* Policy function */+
create or replace function user1.f_policy_chk_dels (
object_schema in varchar2,
object_name in varchar2
+) return varchar2+
is
out_string varchar2(400) default '1=2 ';
+/*+
* out_string is the return value.
* - 'WHERE 1=2' means 'nothing to access'
begin
if ( loc_logged_usr_authorized > 0 ) then
+/*+
* Set the flag deleted to 1
update user1.test_a set deleted = 1 where id = sys_context( 'user1_ctx', 'test_a_id' );
out_string := out_string || 'or 1=1 ';
end if;
return out_string;
end;
+/+
show errors
+/*+
* Create policy
begin
dbms_rls.add_policy(
object_schema => 'user1' ,
object_name => 'test_a' ,
policy_name => 'policy_chk_dels' ,
function_schema => 'user1' , -- function schema
policy_function => 'f_policy_chk_dels' , -- policy function
statement_types => 'DELETE'
+);+
end;
+/+
When I try to delete a record of the table test_a:
conn user1/pwd
SQL> delete from ilogdia.oplsimulaciones sim where sim.id = 9999;
+0 rows deleted+
No rows has been deleted, but the update stmt does not work. That means, the "deleted" flag has not been updated.
Any ideas?
Thank you in advance.
Marco A. Serrano
Edited by: albrotar on Oct 15, 2012 8:42 AM
Edited by: albrotar on Oct 15, 2012 8:42 AM
Edited by: albrotar on Oct 15, 2012 8:43 AMThe policy function is applied once per statement execution. The policy function executes first and the UPDATE statement, presumably, updates no rows because the context is not yet populated. The row-level populates the context (I'm assuming that your session can even see context values populated by an autonomous transaction-- I would guess it could but I'd have to test that) after the UPDATE statement is already complete. The COMMIT in the row-level trigger is also pointless-- it only applies to changes made by the current autonomous transaction, of which there are none-- it cannot apply to changes made in other autonomous transactions. Declaring the row-level trigger to use autonomous transactions doesn't seem to accomplish anything other than to open the question of whether the values set in the context by the autonomous transaction are visible in the caller's transaction.
Even if this, somehow, did work, using autonomous transactions would be a very bad idea since Oracle is free to roll-back a partially executed statement (and the work done by its triggers) and re-execute it. Oracle does that with some regularity to maintain write consistency.
Justin -
How to convert data from rows into columns
Hi,
I have a sql table and the data looks like this
GLYEAR GLMN01 GLMN02 GLMN03 GLMN04
2007 -109712.40 6909.15 4758.72 56.88
2007 -13411.32 19132.9 -5585.07 4362.64
Where GLyear reprsents Year and GLMN01 is February, GLMN02 is March and so on,
Now i want my output to be something like this which i want to insert into another table
GLYear GLMonth GLAmount
2007 February -109712.40
2007 March 6909.15
2007 April 56.88
My new table has 3 columns, GLYear,GLMonth,GLAmount.
Can someone please help me with the select statement on how to do this, i can work with the inserts.
Thanks.I want you to check these form tread they have the same discussion as you. They will definitely solve your problem
http://blog.jontav.com/post/8344518585/convert-rows-to-columns-columns-to-rows-in-sql-server
http://dba.stackexchange.com/questions/19057/convert-rows-to-columns-using-pivot-in-sql-server-when-columns-are-string-data
http://stackoverflow.com/questions/18612326/how-to-convert-multiple-row-data-into-column-data-in-sql-server
I hope this helps you in solving your problem.
Please remember to click “Mark as Answer” on the post that has answered your question as it is very relevant to other community members dealing with same problem in seeking the right answer -
How to convert a word document into the PDF format?
Please instruct me step by step on how to convert several Word documents into the PDF format?
If properly installed and updated (depending on the WORD version), you can simply do any of the following:
1. Open the doc in WORD and select Print, choose the Adobe PDF printer, print.
2. Open the doc in WORD and go to the Acrobat menu in WORD and select create PDF (this uses PDF Maker).
3. Open the doc in Acrobat and the conversion should be done based on PDF Maker. -
How to convert an NWDI project into a Local project?
Hi Experts,
Please tell me " how to convert an NWDI project into a Local project? "
If you cHi Srini
1. Copy/Paste Webdynpro components in the new project as was suggested before
2. Or create new project, copy _comp folder from old project to the new one. But, do not forget to update .dcdef & .project files manually after this. You have to set the correct project name in .dcdef and set the correct local project path in .project.
BR, Sergei -
Hi...
2.....how to convert normal function module into remote enabled function module?
thanks and regards,
k.swaminath.Hi,
In the attributes tab select radio button as remote enabled instead of normal..
u can call the remote enabled fm as...
CALL FUNCTION <Function module> destination <destination name>
Regards,
Nagaraj -
How to convert a PDF file into a full editable WORD file?
Hi,
I tried to convert a pdf file into word but it is not fully editable. I can edit the title from the main page and that's it. The rest of the word document is saved as image. I tried editing teh pdf file but that one is not working either.
Please help on how to convert a PDF file into a full editable WORD file.
Thank youNot all PDF files are created equal. When a PDF file is created with Adobe Tools it is usually "tagged" with information about the fonts the images, the layout etc... This way when the PDF is saved to a new format like PPT or DOC then the results are usually usable. However, if you have a PDF file that was not tagged for some reason then run the Accessibility tools on the PDF to acquire some basic tagging. This may get you a better result. Also if you have a PDF that is an image, then you may want to run OCR on it.
-
How to convert my MM alias into an AppleID to use it with iCloud?
I used MobileMe and created a mail that became my Apple ID. Then I created an alias that became my main e-mail so now with iCloud I wish that aslias could become my Apple ID. I don't care to loose the first Apple ID but "How to convert my MM alias into an AppleID to use it with iCloud?"
You cannot convert an alias to Apple ID.
You can transfer your MM to iCloud with your main Apple ID.
There will be your alias as well.
Regards -
How to convert an int variable into String type
hi everybody
i want to know how to convert an interger variable into string variable
i have to implement a code which goes like this
Chioce ch;
for(int i=0;i<32;i++)
// here i need a code to convert the int variable i into a string variable
ch.add(String variable);
how do i convert that int variable i into a String type variable??
can anyone help me?Different methods:
int a;
string s=a+"";or
String.valueOf(int) is the better option because Int.toString() generated an intermediate object to get the endresult
Ema -
How to Convert Oracle Apps Report into XML Publisher
Hi
How to Convert Oracle Apps Report into XML Publisher?
ThanksIn Brief :
Re: XML Publisher
In Details :
http://www.oracle.com/technology/products/xml-publisher/docs/XMLEBSRep.pdf -
i can't find this anywhere... how to convert mp3 (not music) into text without spending much $$$.
function(){return A.apply(null,[this].concat($A(arguments)))}
hope1hope2 wrote:
i can't find this anywhere... how to convert mp3 (not music) into text without spending much $$$.
It's very unlikely that you'l
l find any help here; this forum is used only
for testing purposes. Unfortunately, I cannot suggest
another forum
Extra line breaks kindly supplied by the software. -
How to convert trailing minus sign into the leading minus sign
Hi
Can any plz tell me How to convert trailing minus sign into the leading minus sign? I mean in PI the amount filed shows like 150.00- i want to convert that into -150.00.
Thanks
GovindaHi Shabarish,
The code works but what if the input is something like [ 10.000-] i.e. with some spaces before 10.000- and the output as per your code comes as [- 10.000]. How do we tackle such cases if there is inconsistency in data i.e. some values come as [ 10.000-] i.e. spaces before the number and some values as [12.000-].
The output of this will come as
[- 10.000]
[-12.000]
How to make it as
[-10.000]
[-12.000]
Regards,
Shaibayan -
How to convert a protected document into a PDF?
Hello,
I need to develop a plugin that needs to convert a protected document in office format into a pdf. I looked into the sdk and found the method AVConversionConvertToPDFWithHandler (). But can this method also apply the digital rigths of the protected document to the newly created pdf?
Is there any other way to convert a protected document into a pdf and at the same time apply the rights to the pdf? I don't want to use Adobe LiveCycle for digital rights management.
What are the requirements to develop a DRM plugin for acrobat?
Please Help!
Thanks in advance!The AVConversion APIs will use Office itself to perform the conversion (well, the rendering part). I would ASSUME that when Office opens the document, it will ask for any necessary passwords or other information to determine if the user has the rights to view and/or process the content of the document. If they do, then the conversion will succeed otherwise it will fail. The PDF will not have any DRM applied to it, since we don't know anything about the Office DRM options.
If you wish to apply DRM to the PDF, you will need to do that yourself or using tools such as LiveCycle Rights Management.
From: Adobe Forums <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Date: Tue, 29 Nov 2011 02:26:37 -0800
To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
Subject: How to convert a protected document into a PDF?
How to convert a protected document into a PDF?
created by poortip87<http://forums.adobe.com/people/poortip87> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4051919#4051919 -
How to Convert a Planned Event into Firmly Booked Event
Dear All,
How to convert a planned event into firmly booked event?
Warm Regards
Vinod KumarCreated Template in active status.
-
How to convert a waveform signal into array of complex numbers
How to convert a waveform signal into array of complex numbers.
Hi Chaks,
try this:
(Get Waveform components, convert to complex DBL)
Message Edited by GerdW on 01-28-2008 09:23 AM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
ToCDB.png 1 KB
Maybe you are looking for
-
I've had my X220 for about a year now. At first, I didn't experience any problems with the fan, no revving up/down like some describe, and it was pretty quiet. After about 9 months of usage, the fan started to get pretty noisy. As I also usually have
-
How to find where the coding of the fields displayed in the standard transactions is written.FOr example In XD0l if I want to find out where the 'key term' is coded in the stadard programe of the transaction XD01.When I go into sytem--->status,I will
-
Controlling Session State and Submit Processing
I am trying to gain a fundamental understanding of how to control submit processing and session state, etc. For example, I have a popup lov that lists names and returns id for the parent record. When the user make the selection using this pop lov, I
-
I have tried to delete the song that is stuck, I have "rebooted" / shut down my phone completely using the power button and home button, I have gone to itunes on my computer to the 'downloads' option in the menu bar and selected complete all download
-
Transport has no efect in PRD server
Hi, NW2004s, Oracle 10g, Windows 2003 OS In BI-7 I created one transport (some DOSDTPTransformationDSInfo-packages in one Transport number when I move to QA just warning shows and its efects in QA When I move in PRD I got an error Method Execution an