SQL & PL/SQL :: Logic For Update And Delete?

Apr 28, 2012

i have three tables: ot_req, ot_po_breakup, and ot_po. when a row is inserted into the ot_po table reffering to ot_req,there is a trigger which creates a seperate reocrd in ot_po_breakup with the details of ot_req ot_req.ri_sys_id as pb_ri_sys_id and ot_req.ri_qty as pb_ri_qty ,pi_sys_id as pb_pi_sys_id .upto this part is okand when i insert also the logic is okay.

i have created a trigger to update the rows in the ot_po_breakup table after insert on ot_poin order of pb_ri_sys_id and pb_pi_sys_id and try to update the values in the columns pb_ves1q, pb_ves2q, and pb_ves3q order. i am trying to take the quantities in ot_po.pi_qty and insert them into the pb_ves1q, pb_ves2q, and pb_ves3q columns of ot_po_breakup where those columns are empty (0 or null) such that the sum of those three columns for that row does not exceed the pb_ri_qty in that row.

My problem is i need to mofify my trigger to do the update and delete , that is whenever the user is updating the column ofot_po.pi_qtythe qty should in ot_po_breakup should get updated accordingly and sum of pb_ves1q,pb_Ves2q and pb_ves3q should be equal to pb_ri_qty and do the same for delete as well

CREATE TABLE OT_REQ
(
RI_ITEM VARCHAR2(20 BYTE),
RI_SYS_ID NUMBER,
RI_QTY NUMBER

[code]...

View 14 Replies


ADVERTISEMENT

SQL & PL/SQL :: Same Logic When AFTER INSERT OR UPDATE Trigger Is Written

Feb 19, 2011

SQL> CREATE OR REPLACE TRIGGER TRI_COMPL_FEATURES
2 AFTER INSERT OR UPDATE ON COMPLEMENTS FOR EACH ROW
3 DECLARE
4 v_fno NUMBER;
5 v_tab VARCHAR2(30);
6 v_unique_id VARCHAR2(40);
[code]....

Trigger created.When I am trying to insert into complements table it is throwing error as follows:

SQL> insert into complements values(19,NULL,'5',6,7,NULL,'W2023648',NULL,NULL);
insert into complements values(19,NULL,'5',6,7,NULL,'W2023648',NULL,NULL)
*
ERROR at line 1:
ORA-20010: ORA-04091: table TEEMNGWS.COMPLEMENTS is mutating, trigger/function
may not see it
ORA-06512: at "TEEMNGWS.TRI_COMPL_FEATURES", line 19
ORA-04088: error during execution of trigger 'TEEMNGWS.TRI_COMPL_FEATURES'

I can understand that I am trying to perform DML operation(i.e select) on table which trigger is fired.But how can I implement the same logic when AFTER INSERT OR UPDATE trigger is written.

View 1 Replies View Related

SQL & PL/SQL :: Update And Delete Using Loader?

Mar 14, 2012

i have a flat file with fixed positions.Records of this file are having like empid empname deptname typeEx:

100 AAAA ADEPT I
101 BBBB BDEPT I
102 CCCC CDEPT U
103 DDDD DDEPT I
104 EEEE EDEPT D

Here value of type would be like I or U or D I have to load this file into oracle table in such a way that

if type value is I then i have to insert into table
if type value is U then i have to update this record in table
if type value is D then i have to delete this record from table.

I am using oracle10g.

View 3 Replies View Related

SQL & PL/SQL :: Cannot Update And Delete Row From Database

Jan 31, 2011

I can not update and delete row from database

View -1 Replies View Related

Delete / Update From XL Sheet To Oracle?

May 7, 2008

have one XL sheet Doc that has 2 tabs. One has the list of keywords for deleting the records from Oracle that has the keywords in it. The second one needs the update query. Read the first column in the XL sheet and replace it with the second column value for the records that has the first column value in it.

I never worked in the combination of XL and Oracle.

View 3 Replies View Related

Delete Record In Update Trigger?

May 24, 2012

the following case is successfully done with mssql databases.

Case:

Table UserGroup
Columns id, name, handshake

When the handshake is set to 'd', this record should be deleted. I know it is bad behaviour by design.

What have I done so far:

- created an after update trigger (mutual error) Caused by trying a delete action in the update action, not possible.

- created a view in combination of instead of update trigger.

This causes also mutual error, or if ignored (PRAGMA AUTONOMOUS_TRANSACTION), an deadlock.

Code so far:

create or replace procedure Delete_UserGroup_sp(p_groupId in USER_GROUP.HMIUSERGROUPID%TYPE, p_handshake in USER_GROUP.HANDSHAKE%TYPE)
is
begin
if p_handshake = 'd' then
delete USER_GROUP WHERE HMIUSERGROUPID = p_groupId;
commit;
end if;
end;

create or replace view USERGROUP_V as select * from USER_GROUP

create or replace trigger USER_GROUP_T1
instead of update on USERGROUP_V
for each row
declare
PRAGMA AUTONOMOUS_TRANSACTION;
begin
Delete_UserGroup_sp(:new.HMIUSERGROUPID, :new.HANDSHAKE);
end;

View 5 Replies View Related

SQL & PL/SQL :: Procedure Has Got Several Update And Delete Statements

Oct 23, 2013

One of the procedures that am working on is failing with ORA-0000: normal, successful completion error.

The procedure has got several update and delete statements and have logging enabled after each step. The problem with that again is, each time the log table gets updated thereby losing the history of until what point the procedure ran successfully.I have this issue only in production environment and unable to simulate it in dev environment which limits my options of troubleshooting the procedure code. I was using SQLERRM in the code.

Is there a way I can identify the bad records/ record causing this issue? Am very new to PL/SQL and do not know how to proceed with this.How do you debug this sort of issues??(where one procedure internally invokes another one which again invokes other one etc)

View 27 Replies View Related

SQL & PL/SQL :: How To Write Single WITH For A Update And Delete

Mar 13, 2012

Can I achieve the merge (update-only) and delete in a single SQL statement?

merge into table_4
using
(select table_3.col1 col1,table_3.col2 col2,
from table_1, table_2, table_3
where
[code].....

delete from table_3 where <records identified in the 'using' clause of above merge>;

i.e.

delete from table_3
where (table_3.col1,table_3.col2)
in ( select table_3.col1,table_3.col2,
from table_1, table_2, table_3
where
join conditions.....
other conditions ....
group by table_3.col1, col1,table_3.col2
having count(*) >1 );

What I want is roughly as following :

WITH mywith as ( select table_3.col1,table_3.col2,
from table_1, table_2, table_3
where
join conditions.....
other conditions ....
group by table_3.col1, col1,table_3.col2
having count(*) >1 )
update table_4 set col3='N' where table_4.col1=mywith.col1 and table_4.col2=mywith.col2
delete from table_3 where table_3.col1=mywith.col1 and table_3.col2=mywith.col2;

View 5 Replies View Related

Insert / Update / Delete Trigger Creation?

Feb 6, 2009

I am trying to write a trigger that will do an insert/delete/update into a audit table when a change has occurred on the primary table. The change will be recorded in the audit table by a incemental sequence number and the updated data.

there will be an extra column in the audit table

how to get a simplified version of this trigger.

the primary table will look like so
Id_num varchar (20)
code Integer
desc varchar(20)
sequence_num Integer

audit table
Id_num varchar(20)
code Integer
desc varchar(20)
timestamp date
sequence_num Integer

View 6 Replies View Related

Simulate Delete Operation Through Using Update On Trigger

Jul 27, 2008

I'm trying to simulate a delete operation through using an update on a trigger my tables are

CREATE TABLE EMPLOYEE (
LNAME VARCHAR(15) NOT NULL,
SSN CHAR(9) NOT NULL,
salary FLOAT,
dno INT NOT NULL,
vst DATE,
vet DATE,
PRIMARY KEY (Ssn));
[code]....

What I want to do is whenever there is an update on vet( valid end time) in employee, delete the values from the employee table and insert the old values from employee into the emp_history table along with the new value for vet. Here's my trigger

CREATE TRIGGER trig4
AFTER UPDATE OF VET ON EMPLOYEE
FOR EACH ROW
BEGIN
INSERT INTO EMP_HIST VALUES( : old.LNAME, : old.SSN, : old.salary, : old.dno, : old.vst, :new.vet);
DELETE FROM EMPLOYEE WHERE(SSN = :NEW.ssn AND vet IS NOT NULL);
END trig4;
//ignore the space between : and o as it makes a smily

The problem is I get an error for a mutating change, what I'd like to know is if the above trigger is possible, and if so how to implement it without giving me an error. I mean it makes sense syntactically and logically(at least to me).

View 1 Replies View Related

Audit Delete And Update On All Tables Of Database?

Jun 14, 2013

Was going through this and found that

“AUDIT DELETE ANY TABLE BY <username> BY ACCESS” or “AUDIT UPDATE ANY TABLE<username> BY ACCESS”

enable audit for delete and updates for  given username/schema.  I want to enable auditing on delete and update on my entire database. 

Why? And have we tested it in our any of existing setup?  I am thinking of “Trigger after delete” but again this logic gets struck at individual tables. It do not work simply once and all for complete database/all users/all schemas

View 15 Replies View Related

Get All Tables That A User Can Select / Insert / Update Or Delete

Dec 17, 2010

How to get all the name of tables that a user can select, insert, update or delete?

View 2 Replies View Related

SQL & PL/SQL :: Adding Audit Column To Track Delete And Update

May 15, 2012

we received a design advise to add columns to track the update and delete done on each row in our tables:

- DELETED_DATE_TIME
- DELETED_BY
- UPDATE_DATE_TIME
- UPDATED_BY

In our architecture, the application can only access functions/procedures to access/modify data. Each function logs the action, the executed sql statement, oracle error, user terminal, and the user into a unified log table by using v$ tables to create a general log function that is called after execution or error.

The only advantage is that it will be easier to know the delete and last update information faster versus space and design modification.

View 1 Replies View Related

Oracle Triggers - Separate Actions On Insert / Update / Delete?

Jul 26, 2012

For triggers, is it possible to do separate actions on insert , update and delete. For example, if insert is the case, do select; if update is the case, do select from another table and so on?

View 1 Replies View Related

Forms :: Insert / Update And Delete Single Record At A Time?

Aug 10, 2005

I have multirecord block and I want to disable Inserting/Updating/Deleting more then one record at a time.

View 32 Replies View Related

Application Express :: Unable To Delete Multi Row Update Process?

Dec 8, 2012

I have created a simple page with a tabular form built on a view. The view is on top of a collection that is created when the page is ran. I added a tabular form column validation. I then was going to add a pl/sql process to handle the updates into the db, but before I did that I wanted to delete the ApplyMRU that was created when I first created the tabular form because it does not make sense on my view. When I went to delete the MRU it gave me an error saying "Multi Row Update processes can't be deleted as long as there are validations defined for the tabular form".

I have searched for an answer on this, but so far I have not found much. I am hoping it is something simple that I am missing. I even tried deleting the MRU first and then add the validation, but then it gave me another error about "Tabular form validations require multi-row update processes" I know this was possible in 4.1, but now I am trying it on 4.2

View 2 Replies View Related

SQL & PL/SQL :: How To Get Data In Logic Order

Dec 28, 2010

my table have four cols such as

start_value trans_value result_value create_time
1 4 5 20101018 22:33:40
5 -2 3 20101018 22:33:40
3 3 6 20101018 22:33:40
6 -4 2 20101018 22:33:40
2 +3 5 20101018 22:33:40
5 9 14 20101018 22:33:40

but the data is not in the logic order they are confusing and there no origina sequence such as

start_value trans_value result_value create_time
1 4 5 20101018 22:33:40
3 3 6 20101018 22:33:40
5 -2 3 20101018 22:33:40
2 +3 5 20101018 22:33:40
5 9 14 20101018 22:33:40
6 -4 2 20101018 22:33:40

how to get they in logic order.now i have to create a combination in mem and use loop to get the logic order.

View 6 Replies View Related

SQL & PL/SQL :: Combining New Logic Using Old And New Cursor

Aug 22, 2011

I have to implement a new logic such that , Old logic which pulls data will stay in place.now New logic pull data form SAP . So i have implemented the new logic in to the existing cursor as below.

i.e.

Cursor new_sap
old_query
Union
New_query;

I have 3 new cursor like dis. How to process these old and new cursors in FOR loop.. Ex:

For c1 in C2(order_number)
if order_source is sap then ( dis filters old data which is not in SAP)
new query in cursor should process
else
old query in cursor should process
end if;

How will i do this programatically.

View 1 Replies View Related

SQL & PL/SQL :: Decode Logic Not Working

Feb 19, 2013

what is the right syntax to use the below decode logic.

Decode(EXTRACT(MONTH FROM sysdate) > 2, ltrim_blanks(GLAMOUNTS.CR_AMOUNT_02) + ltrim_blanks(GLAMOUNTS.DB_AMOUNT_02), 0)

View 12 Replies View Related

SQL & PL/SQL :: Query Logic - Students Who Took ALL / ANY Courses

Mar 1, 2011

I need to run a query for students that took ALL the following courses: 6710, 6711, 1032, 1035 and ANY of the following courses: 3061,3065

here is my query:
=SELECT distinct student_number, last_name, first_name, gender, ethnicity, students.grade_level, lunchstatus, course_name, course_number ,termid
from students inner join storedgrades on students.id=storedgrades.studentid
where students.schoolid='0976111'
and (students.grade_level >'9' and students.grade_level <= '12')
and (course_number = all('6710', '6711', '1035')and course_number=any('1031','1032','3061','3065','3062', '3401', '3082'))
order by last_name, first_name, grade_level, course_number

The problem is that I'm not getting any results but I know for a fact that some students took the required courses. On a side note, if I change the ALL to ANY - I do get results - but it is not what I want because it would be hard to keep track of the students that met the requirements.

View 7 Replies View Related

SQL & PL/SQL :: Merge Statement Required With Logic

Jul 10, 2013

Table Name: F_SCENARIO
System : Dataware house
Oracle version : 11g
Record Count : 2 Million records

Correct scenario records

F_Key F_Bridge_key Record_type
1 1 1
2 1 2
3 1 3

Wrong scenario records

F_Key F_Bridge_key Record_type
1 1 1
2 -5 2
3 -6 3

I want to write a Merge statement to update the negative values into 1.

View 6 Replies View Related

SQL & PL/SQL :: Code To Use Instead Of CONTINUE But Have Same Logic Incorporated?

Oct 21, 2010

I have a BEGIN Block of the code where a loop is running .I also have a CONTINUE statement in the EXCEPTION Block of the code where I return the control to the BEGIN Block in case of any exception.Now as per ORACLE Company, CONTINUE has a old issue which is already registered by Oracle Company Bug 7306422.

The issue is where CONTINUE statement does not run properly when your code Optimization level is 2. However it will work properly if we have the Optimization Level as 0 and 1.are facing the same issue here and have a workaround.

Is there any code which I can permanently use instead of CONTINUE but have the same logic incorporated.i.e returning to the next iteration whenever I say to pass the control.

View 10 Replies View Related

Forms :: Web-logic 10.3.5 With Oracle Reports 11.1.2.1.0

Jul 29, 2013

i am trying to upgrade my existing system (6i) to 11g. I have installed Weblogic 10.3.5 with forms and reports 11.1.2.1.0 on windows 7 32 bit. I can connect to my database (10g) from Form builder.

But when I try to open a form/pll of 10g or 6i, it says PDE-PLI018 could not find library and it shows the path of my earlier folder, which now does not exist.

I have made changes in registry FORMS_PATH, FORMS_BUILDER_PATH, UI_ICON And in default.env file FORMS_PATH and CLASSPATH

I have added entry to tnsnames.ora, through which I can connect to DB. And have followed below site to configure weblogic and FM forms and reports;

[URL]

1) Do we have to connect (create a bridge) to DB from weblogic except tnsnames.ora.

2) For library error I think I am missing some settings to be done.

3) If I am able to rectify above error then can I directly use [URL] and access the system from another pc, or still there are some modifications needed.

View 2 Replies View Related

PL/SQL :: Unable To Create Logic Sequence?

Oct 23, 2012

create table t (a varchar2(20),b number(8));
insert into t values ('aa',4);
insert into t values ('ba',6);
insert into t values ('ca',7);
insert into t values ('da',8);

in place of 8 there can be any number between 1 to 100

if in place of 8 number is <10
insert into t values('ea',10); ---- this i need dynamic insert
if in place of the number between 11-19 then
insert into t values('ea',20); ---- this i need dynamic insert
and so on

i tried as below

select case when max(b) <10 then 10 when max(b) between 10 and 20 then 20 end from t;

but i cant write case for again and again upto nth

View 3 Replies View Related

PL/SQL :: Require Logic / Oracle 10g R2 On Windows

Sep 5, 2012

I have oracle 10g R2 on windows.I have two tables and say table A ant Table B. Both have column Total_amount. There are primary key's on Both tables.

Sample query
SELECT A.EMPNO,A.EMP_CODE,nvl(A.TOTAL_AMOUNT,0) "A_TOTAL_AMOUNT",
    nvl(B.TOTAL_AMOUNT,0) "B_TOTAL_AMOUNT",(nvl(A.TOTAL_AMOUNT,0) - nvl(B.TOTAL_AMOUNT,0)) "DIFFERENCE"
    FROM A, B
    WHERE A.EMPNO =B.EMPNO (+)
    AND A.EMP_CODE = B.EMP_CODE (+)
    AND round((nvl(A.TOTAL_AMOUNT,0) - nvl(B.TOTAL_AMOUNT,0)),3) <> 0Above query retrives only Non-matching rows.

I need to retrive :-

1)output of the query shown above and

2)Records which are present in B and not in A.

View 2 Replies View Related

PL/SQL :: Logic To Compare Date With Standard Timestamp

Feb 3, 2013

I want to retrieve the data which is "n" moths old.

To compare that I want use only SYSDATE without timestamp. I want to use standard timestamp '23:59:59' along with SYSDATE.

The condition should be as below.

UPDATE_DATE <= ADD_MONTHS(15/01/2013 23:59:59,-3)
UPDATE_DATE <= ADD_MOTHS(30/01/2013 23:59:59,-4)

UPDATE_DATE<=ADD_MONTHS(sysdate||' '||'23:59:59',-3);

View 6 Replies View Related

Implement Custom Logic On Button In Oracle CRM On Demand

Jun 25, 2013

we wanted to know the approach of how to implement our custom logic through button click (which is vanilla) in Oracle CRM on Demand

View 1 Replies View Related

SQL & PL/SQL :: Find Logic To Query Data Based On A Condition

Aug 18, 2013

find the logic to query data based on a condition like..I am having a table dummy

USERNAME RESP_NAME FUNC_NAME MESSAGE
-------- --------- ------------------ ------------
TEST1 SYS_ADMIN CONCURRENT_PROGRAM AAAAAAAAAAAA
TEST1 SYS_ADMIN % BBBBBBBBBBBB
TEST1 % CONCURRENT_PROGRAM CCCCCCCCCCCC
TEST1 % % DDDDDDDDDDDD
% SYS_ADMIN CONCURRENT_PROGRAM EEEEEEEEEEEE
% SYS_ADMIN % FFFFFFFFFFFF
% % CONCURRENT_PROGRAM GGGGGGGGGGGG
% % % HHHHHHHHHHHH

The above 8 are the possible ways to key in the data using a form.The logic is like based on a particular condition the message should display in the report.If they specify a particular USER and RESP_NAME and FUNC_NAME then it should display AAAAAAAAAAA (This should take priority first). The priority is in order the default should be the last one.

View 22 Replies View Related

Reports & Discoverer :: Middle Ware Web Logic Server

Aug 9, 2013

I installed web logic server and form & report on my linux system and gave configuration option later . so now web logic admin server is running on different port and wls_reports server is running to different port in cluster. How its running on cluster and when i run

localhost:9002/reports/rwservlet/getserverinfo?server="report_server_name" i am getting rep-51002 error.

View 3 Replies View Related

Forms :: Null Values - Logic Error During Runtime?

Feb 28, 2012

I'm having a problem with null values. I want to display old student in a display item if subjects text item has records. Otherwise, display new student if it has null values. This is the code that i tried so far..

IF :block2.subjects IS NULL THEN
:block3.type := 'NEW STUDENT';
ELSE
:block3.type := 'OLD STUDENT';
END IF;

But i got logic error during runtime.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved