SQL & PL/SQL :: Data Manipulation Insert - Procedure / Trigger Should Delete Initial Record Saved

Aug 30, 2012

i have one table ot_ins_item where user will enter the details of item, grade,item qty , later on user will go and update the same table the details of different grades received for the same item in different columns with qty breakup in 3 different fields it_qty_01 , it_qty_02,it_qty_03 respectively with different grades , what i need is i want is whenever he updates this table with different grades based on data entered in 3 different fields , a procedure or trigger should delete the initial record saved and insert three different rows based on newly updated values , it may be 3 or it may be 2 sometime depending upon input values that many records should be inserted same time controlling the qty's entered in breakup not exceeding the main qty.

CREATE TABLE ot_ins_item (it_ins_no NUMBER,it_no NUMBER,it_grade VARCHAR2(12),
it_code VARCHAR2(12),it_qty NUMBER,it_flex_01 VARCHAR2(12),
it_01_qty NUMBER,it_flex_02 VARCHAR2(12),it_02_qty NUMBER,it_flex_03 VARCHAR2(12),
it_03_qty NUMBER);

create sequence s_it_no start with 1 ;

INSERT INTO OT_INS_ITEM VALUES (1,s_it_no.NEXTVAL,'A','ITEM1',NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO OT_INS_ITEM VALUES (1,s_it_no.NEXTVAL,'B','1TEM2',NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO OT_INS_ITEM VALUES (1,s_it_no.nextval,'C','ITEM3',NULL,NULL,NULL,NULL,NULL,NULL);
SELECT * FROM OT_INS_ITEM;
[code]....

View 5 Replies


ADVERTISEMENT

Forms :: How To Delete Record When Saved Through Post Keywords

Aug 6, 2011

i m using oracle 10g forms. in one form i m using post keyword when i use this function then records saved in temporary database but i want to remove one record from this form but it is allrady saved through post.

View 1 Replies View Related

SQL & PL/SQL :: Trigger Fires On Deletion Of Uncommitted Data And Changes Saved

Dec 26, 2012

Maybe you can tell me if you think it's right or wrong for Oracle to behave like that. What basically happened is that I've set up a trigger to capture deleted rows from testtab into testtab_del.

I have inserted and immediately after - deleted a row from testtab. Then I inserted another row, committed, and checked my testtab_del table.

I've seen that val1 was inserted and committed into testtab_del. This happened in spite of the fact that this row never existed as a *committed row*.

What do you think about this behavior in this scenario? Works as designed or not?

SQL> show user
USER is "ANDREY"
SQL> col tcol for a10
SQL> drop table testtab;

[Code]....

View 17 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 :: Hierarchy Record Manipulation?

Jun 13, 2011

Ihave the following result set based on a hiearchy query

SELECT LEVEL ,
BM.ITEM item
BM.Part part
connect_by_isleaf leaf
FROM item_part_tab bm
START WITH bm.item_id='002PH'
CONNECT BY BM.ITEM_ID = prior BM.PART_id

LEVEL ITEM PART LEAF
-----------------------------------------------------------------
1 002IT XPART1 0
2 XPART1 SUBPART1 1

In the above resultset PART='SUBPART1' does'nt have any child as evident from the connect_by_isleaf (LEAF=1) .Is there any way to create a pseudo record if such values are returned by the query, i.e., if a part has no tree under it a dummy record should be created i.e. in this case an additional record should be returned by this query. i.e., as below. the LEVEL=3 record should be created.

LEVEL ITEM PART LEAF
---------------------------------------------------------
1 002IT XPART1 0
2 XPART1SUBPART1 1
3 SUBPART1 1

View 16 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

Forms :: Delete A Record By Writing Code In When_button_pressed Trigger

May 4, 2010

How can I delete a record by writing code in when_button_pressed trigger.

View 8 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

SQL & PL/SQL :: Trigger To Insert Record Into Another Table

Aug 17, 2010

writing a trigger body. My requirement is i need to insert a new record in a task table when ever a new record is inserted into employee table.Here in the trigger i need to select the name of the employee in the last inserted row in employee table and insert the name in task table.I tried to write the code as below

insert into task(name, date, type) values ((select name from employee where emp_id=(select max(emp_id) from employee), sysdate, 'document'));

When i am trying to insert record using trigger, it is taking last but one record from the employee table.

View 2 Replies View Related

Forms :: Only New Record Have Saved Last Record No Longer Exist

Jun 29, 2013

I create a data block on a table when I am inserting new record only one record have been saved. Last record no longer exist.

View 4 Replies View Related

Forms :: Record Is Getting Saved Twice

Mar 8, 2012

My record is getting saved twice every time I push my button to commit changes to my DB.I have already records from my table and when I click for that record to update the grade. the same record is getting saved twice.I have put my queries in on-update trigger to update the grade of my record. I check my query, don't have errors. I don't know what's wrong with this.

View 24 Replies View Related

Forms :: Record Count - Applied And Saved?

Jan 27, 2010

Why showing at the status bar "3 records applied and saved" instated of "2 records applied and saved". 2 means 1 for Header and 1 for Detail. How I change status bar.

View 7 Replies View Related

SQL & PL/SQL :: Data Manipulation Operation Not Legal On View

Jan 11, 2012

CREATE TABLE TEST(FIRST VARCHAR2(10),SECOND VARCHAR2(10));
INSERT INTO TEST VALUES('AA','BB');
INSERT INTO TEST VALUES('AA','BB');
INSERT INTO TEST VALUES('bb','aa');
INSERT INTO TEST VALUES('bb','aa');
COMMIT;
SQL> SELECT * FROM TEST;

[code]....

ORA-01732:data manipulation operation not legal on this view

I want to delete the Repetitive data,What's wrong with these SQL statements?

View 1 Replies View Related

Forms :: How To Read Values In A Multi Record Control Block Using Pre-insert Trigger (block Level)

Jul 24, 2010

I have a multi record control block (basically a text item displaying 6 records) where user enters values and I want to process the values using pre-insert trigger.

I want to read value in each record and then do some tasks using a pre-insert trigger before I commit the values. To navigate between the records I was using first_record, next_record, clear_record built-ins but it gives errors like "40737-illegalrestricted procedure next_record in pre-insert trigger".

View 3 Replies View Related

How To Insert A New Record In A Data Block

Sep 18, 2012

How do I insert a new record in a Data Block, and the standard is always insert a line below, you could add a record above?

View 1 Replies View Related

SQL & PL/SQL :: Creating Trigger - Check If Data Being Inserted Already In Table And If Not Insert It

Aug 24, 2011

I know this is an old thread and I just started working with triggers. I want to check if the data being inserted is already in the table and if not insert it:

create or replace trigger t_triggername
before insert on tbl_tablename
for each row
begin
if(:new.user_id <> :old.user_id) then
insert into tbl_tablename(user_id, location)
values (:new.user_id, :new.location);
end if;
end;

what if I wanted to keep the user but only update location if the user is already in the table. I've tried doing it this way:

create or replace trigger t_triggername
before insert on tbl_tablename
for each row
begin
if(:new.user_id <> :old.user_id) then
insert into tbl_tablename(user_id, location)

[code]...

View 4 Replies View Related

How To Check And Insert New Data Using Stock Procedure

Feb 11, 2007

i've a problem in using store procedure. My code is to get postcode id when i pass a postcode. First it will check the postcode that i pass if already exist it will get postcode id but if not it will insert new postcode and get a new postcode id created then pass into ASP system. When i try run this stock procedure i got error as below :-

SQL> exec INSERT_PCODE_GMDS
BEGIN INSERT_PCODE_GMDS; END;

*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INSERT_PCODE_GMDS'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

(
Postcode1 IN varchar2,
citiID IN Number,
county_ID IN number,
city_name IN varchar2,
sub_cityID IN number,
pcode OUT number
)
[code].......

in ASP to pass and get back the values i used code as below. but i think the problems occurs in my stock procedure

set cmd=Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = OBJdbConnection
cmd.CommandText="INSERT_PCODE_GMDS"
cmd.CommandType= 4
cmd.Parameters.append cmd.CreateParameter("@poskod",adVarChar,adParamInput,5,poskod)
[code].......

View 1 Replies View Related

SQL & PL/SQL :: Procedure To Update Or Insert Data In Multiple Tables

Apr 9, 2011

I'm writing a Procedure which Updates or Inserts data in Multiple tables. Selected fields of 10 tables need to be updated or Inserted. For this I created a table which comprises of fields related to all 10 tables. Then I write Procedure. Under this I create a Cursor which uploads the data from the newly created table which contains different fields of 10 tables. Then I write Update and Insert statements one by one for all 10 tables.

Sample Procedure below.
-------------------------------------------
Create or replace procedure p_proc as
spidm spriden.spriden_pidm%type;
cursor mycur is select * from mytable;
begin
for rec in mycur
[code]......
----------

Note: I created table on my server because data is coming from different server. They will upload the data in the table from there I pick and update the tables. Is updating or Inserting data in different tables one by one is correct?

View 15 Replies View Related

Forms :: When User Change / Delete Any Record / Row In Forms Data Automatically Move To Other Table

Dec 25, 2011

when a user change or delete any record or row in forms data automatically move to other table because i want to compare old and new record.

View 8 Replies View Related

Forms :: Data Not Getting Saved In Database

Oct 4, 2012

i have a datablock with a list item and display item.and after selecting the list item (registration number),corresponding data gets filled into the display item.but when I click the save button(ok) data doesn't go into the database,

View 1 Replies View Related

Client Tools :: INSERT INTO With GUI - Insert Record Greyed Out?

Oct 28, 2013

I wish to make this simple statement with Toad GUI

INSERT INTO EXCLUDE_xxx
VALUES ('xxx',
'xxx',
'xxx',
'xxx',
SYSDATE);

Insert record is greyed out. How to insert new rows with Toad (click click)?

View 7 Replies View Related

PL/SQL :: Create Trigger To Insert Data From One User To Another User In Same Database?

Apr 16, 2013

I Created One Trigger as Follows

CREATE OR REPLACE TRIGGER TRIGGER1
BEFORE INSERT
ON table1
FOR EACH ROW

[code]......

Here , I Want To Insert The Data From My User To Test User . In This Situation When I Execute The Above Trigger It Shows The Error PL/SQL: ORA-00942: table or view does not exist

View 3 Replies View Related

Forms :: Windows Close / Click On Save Button Data Get Saved

Jun 29, 2010

i design one master detail block and one command button for saving the data....as i click on save button data get saved and after that if i want to close form then at this time it again asking me for save changes window..

View 8 Replies View Related

Data Guard :: Error Occurred During Initial DB Duplicate To Standby Server?

Mar 20, 2008

i have setup the OEM-Dataguard in order to duplicate the DB instance from the primary to the standby DB in the standby server.At first I installed oracle server in Server A (Primary) created DB instance of SCT, in archivelog mode and then I install the oracle binary in Server B (standby) and made 2 servers ORACLE_HOME the same and also I installed OEM agents on the 2 servers and registered successfully to the OEM server.

I then used the dataguard to do the initial backup of the DB in server A and but when I specify the standby DB location, it prompt me the following error.

Error

Examine and correct the following error(s), then retry the operation.
Remote Operation Error - Internal error occured

Add Standby Database: Database Location

Primary Database SCT
Primary Host Ent
Step 3 of 6

Standby Database

* Instance Name The instance name (also referred to as the SID) must be unique on the standby host. Database Storage File SystemRaw Devices Choose whether the database files will be put on a conventional file system or on raw devices.

Standby Host Credentials

Enter the credentials of the user who owns the Oracle installation in the Oracle Home selected below.
* Username
* Password

Standby Database Location

The standby database can be created in any Oracle Home that has been discovered by Enterprise Manager. Only Oracle Homes on hosts that match the operating system of the primary host are shown. Select the Oracle Home in which to create the standby database.

Search For Host
Select Host Oracle Home Oracle Server Version Operating System Operating System Version
Ent /u01/app/oracle/product/10.2.0/db_1 10.2.0.1.0 SunOS 5.10
Ent_standby /u01/app/oracle/product/10.2.0/db_1 10.2.0.1.0 SunOS 5.10

View 2 Replies View Related

Multiple Record Insert Using INSERT ALL

Jan 2, 2009

I'm trying to insert only a few columns (not all of them) from temp_ioi_010209 into mtl_system_items_interface. Both of these tables have more columns than just the 7 I'm specifying but everything I found under INSERT ALL here makes me think I'm doing it right. According to the DESCRIBE of mtl_system_items_interface the only non-nullable column is set_process_id and I'm specifying that one...

Why I'm getting the error "ORA-00947: not enough values"?

INSERT ALL INTO mtl_system_items_interface
VALUES
(process_flag,
transaction_type,
set_process_id,
[code].......

View 3 Replies View Related

SQL & PL/SQL :: Make A Trigger That Don't Allow Delete?

Jun 11, 2013

Well I need to make a trigger that don't allow delete departments in the next 3 month.

I dont know how to start it :/

View 23 Replies View Related

SQL & PL/SQL :: Delete Duplicated Record

May 21, 2010

I want to delete the duplicated record using following methods, it delete the records if all the record are matched according to condition, but if all records are not matched then it display error messages.

SQL> SELECT * FROM XYZ;

NAME FNAME ADDRESS JOB
-------------- -------------------- -------------------- -----------------------------------------
Bilal Khan Wali your rehman name district abbottabad student
Bilal Khan Wali your rehman name district abbottaba student
Bilal Kh Wali your rehma name district abbotta studen
Bilal K Wali your rehm name district abbotta studen
Bilal Khan Wali your rehman name istrict abbottaba tudent
lal Khan i your rehman name strict abbottaba tudent
[code]....

View 6 Replies View Related

SQL & PL/SQL :: Delete Record From A Table

Oct 14, 2010

I have tried the following delete statement but it is taking long time,and it's not giving any result.

DELETE FROM hs_table WHERE sno=1234 and effdt='25-MAY-10';

The records in the table are 90000.And we are deleting only one report.

View 6 Replies View Related

Forms :: How To Delete Record

Jun 27, 2011

i m using oracle 10g forms

in one form

there are multiple records shown in this form

i m using one delete button

coding is

declare
v_yes_no varchar2(1);
begin
v_yes_no:=display_alert2('alert_2','Caution','Do you want to delete current record');

[Code]...

but when i press this button then one message shown on secreen

you can not delete this record

when i debug the form

message shown through on error trigger

i can not understand why this message ocuured

and record not deleted

no any constraint use in this form

but if i delete record from backend then records delete successfully

View 2 Replies View Related

SQL & PL/SQL :: Duplicate Record - Delete?

Apr 8, 2012

I have a requirement to delete duplicate records. For example,if the below query retrieves count of duplicate records along with the column values.

select col2,col3,col4,col5,col6,col7,count(*) from table
group by
col2,col3,col4,col5,col6,col7
having count(*) > 1;

I would like to retain only one record with max(col1) which is a surrogate key and other records should be deleted.How to retain one record in a duplicate record set based on max of certain column.

View 14 Replies View Related







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