Unable to insert the record to table using pre-insert & pre-update trigger
Hi All,
I have tried to insert and update the backend table using the pre-update and pre-insert triggers. But its not working for me. Please find below the code which i have used in the triggers.
Pre-insert trigger:
DECLARE
v_cust_num_cnt NUMBER;
BEGIN
SELECT COUNT(customer_number)
INTO v_cust_num_cnt
FROM cmw_bc_mobile_number
WHERE substr(customer_number,1,15)=substr(:BLOCKNAME.CUSTOMER_NUMBER,1,15);
IF v_cust_num_cnt = 0 THEN
INSERT INTO cmw_bc_mobile_number (CUSTOMER_NUMBER
,MOBILE_NUMBER
,CREATION_DATE
VALUES
(substr(:BLOCKNAME.CUSTOMER_NUMBER,1,15)
,:BLOCKNAME.MOBILE_NUMBER
,SYSDATE
COMMIT;
END IF;
END;
PRE_UPDATE TRIGGER:
BEGIN
IF :SYSTEM.RECORD_STATUS = 'CHANGED' THEN
UPDATE apps.cmw_bc_mobile_number
SET mobile_number = :BLOCKNAME.MOBILE_NUMBER,
creation_date = SYSDATE
WHERE customer_number=substr(:BLOCKNAME.CUSTOMER_NUMBER,1,15);
COMMIT;
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
Please let someone assist in gettting it resolved.
Regards,
Raj.
Just use MESSAGE (we don't know what fnd_message is, that is some custom code):
message('v_cust_num_cnt='||v_cust_num_cnt);
IF v_cust_num_cnt = 0 THEN
message('Now inserting...');
INSERT INTO cmw_bc_mobile_number (CUSTOMER_NUMBER...
else
message('Nothing to insert');
end if;
Similar Messages
-
Inserting rows in 2 tables using a single query
Can we insert values in two tables using a single INSERT query?
Yes we can insert data in multiple tables using (Multiple insert statement (oracle 9i New Feature))in a single statement.
ex:
INSERT ALL
INTO sal_history VALUES(empid,hiredate,sal)
INTO mgr_history VALUES(empid,mgr,sysdate)
SELECT employee_id EMPID, hire_date HIREDATE, salary SAL, manager_id MGR
FROM employees;
sncr
Naresh -
Triggers to insert the record in a table
I have two table 1. Holiday 2. Attendance.
When I insert the record in holiday table for his
advance holiday with empid, the same time I want to insert it attendance table
automatically for the same date using a trigger
Insert into attendance (empid,date,holiday) values (20078,07/10/2014,1). If holiday column value 1 represent holiday marked,
0 represent holiday not marked. The same thing can happen vice versa
If employee mark his current attendance as holiday through attendance,
it should be inserted into holiday table
automatically using triggers.
Insert into Holiday (empid,date,holiday) values (20078,06/08/2014,1). If holiday column value 1 represent holiday marked,
0 represent holiday not marked. The same thing can happen vice versa
Please I am looking for your help , how I can make it using triggers
to insert both table in two different ways of options.
Regards
Pol
polachanHi polachan,
According to your description, if you want to synchronize the data between the holiday table and the attendance table while inserting records into holiday table, you need to create a trigger on the holiday table, please try the following syntax.
use <databasename>
go
create trigger Tr_holiday
on holiday
for insert
as
declare @empid varchar(20),
@date datetime,
@holiday int
select @empid = empid, @date=date, @holiday=holiday from inserted
declare @qty int
select @qty =count(*) from attendance where empid=@empid and date=@date and holiday=@holiday
if @qty<1
begin
insert into attendance
select i.empid,
i.date,
i.holiday
from inserted i
end
Meanwhile, if you want to insert the record into the holiday table when holiday is updated to 1 in the attendance table, you need to create another trigger on the attendance table, please try the following syntax.
use <databasename>
go
create trigger Tr_attendance
on attendance
for update
as
declare @holiday int
if update (holiday)
begin
select @holiday=holiday from inserted
if @holiday=1
begin
insert into dbo.holiday
select empid,
date,
holiday
from inserted
end
end
For more details about creating triggers in SQL Server, please review this article:
CREATE TRIGGER (Transact-SQL).
Thanks,
Lydia Zhang -
How Can insert the records into Excel_sheet by using SQL Task-SSIS ?
As per requirement ,
insert the records in excel sheet(DT) by using SQL Task-SSIS .
I used SQL query in SQL Task-SSIS:
e.g.., INSERT INTO [DT$B1:B1] VALUES ('COMMM')
but error:Executing the query "INSERT INTO [DT$B1:B1] VALUES ('COMMM') " failed with the following error: "This table contains cells that are outside the range of cells defined in this spreadsheet.". Possible failure reasons: Problems
with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Please any suggestion ...
-MADHUthen first create a table inside Excel sheet based on your source data. You can Execute sql task for that using excel connection. then use insert to populate it
see an example here where I create a dynamic sheet using execute sql task
http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to insert the records using sql query
hi,
i insert the record uisng sql query and DOTNET programme successfully and increase the doc num .ubut when i try to add record using SAP B1 the old Doc no show.It means its not consider the docnums which are not inserted by sql query.
how can i solve this problem?
Regards,
M.Thippa ReddyYou are not support use Insert / Update / Delete on SAP Databases directly.
SAP will not support any database, which is inconsistent, due to SQL-Queries, which modify datasets or the datastructure of the SAP Business One Database. This includes any update-, delete- or drop-statements executed via SQL-Server Tools or via the the query interface of SAP Business One
Check SAP Note: 896891 Support Scope for SAP Business One - DB Integrity
[https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/smb_searchnotes/display.htm?note_langu=E¬e_numm=896891] -
How to update and insert the records without using Table_comparison and Map_operation?
Use either join or MERGE see this Inserting, Updating, and Deleting Data by Using MERGE
-
Unable to map the record variables in SubProcess
Hi All,
We are using Oracle BPM 11g.In my requirement,we are using one database adapter for selecting the records from table,after that we are using the subprocess to loop the process record by record,we also created the busines data objects and process data objects for group of records(record array) and single record of table record type(table which I selected in database adapter),we maped those variables in subprocess,but it is showing error as the variables are not valid.we are unable to map the each array value to single record,Can any body help out from this problem.Please share any example related to above senario.
Thanks in Advanced.
Parker,
Edited by: parker on Mar 28, 2011 12:31 AMHi Ammad,
Thanks for your Reply.Actually that block is based on a complex view(xxmz_sc_detail_v).So i am trying to insert the data into one custom table(xxmz_ship_confirm).so i have written following code in the KEY-COMMIT trigger:
BEGIN
LOOP
IF :xxmz_detail.select_cbx = Y then
INSERT INTO xxmz_ship_confirm
values(:xxmz_detail...,....,...);
END IF;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
NEXT_RECORD;
END LOOP;
END;
APP_STANDARD.EVENT('KEY-COMMIT');
execute_query;
At this block if i make any changes after i press F4 It's prompting "Do u want to save the Changes?[YES/NO/CANCEL].
If i press "YES" it displays message "1 Records applied and Saved.
But the record is not saved in the xxmz_ship_confirm table.
Thanks, -
Hi Gurus,
Am able to insert , update records in EXCEL sheet using JDBC. But am unable to delete the record from EXCEL sheet. Please give me the solution how to delete the record from EXCEL sheet
Thanks in Advance
RaviThe excel odbc driver (which has nothing to do with java) doesn't do that. See "Excel Driver Limitations" in the following....
http://support.microsoft.com/kb/178717 -
Meeting trouble when inserting a record into dababase using JDBC.
Hi, everyone!
If I want to insert a record in a table of a database, but I
do not know whether there is already a primary key existing in
the database (I mean the value of the record which I want to insert
conflicting, i.e. duplicating, with one of the value of primary
key in the database). So, I have two solutions:
1. check whether there is already a primary key which confilcting
with the value I want to insert, if not, insert into database.
2. do not do any check before and insert the record directly, and catch
SQLException.
But they both have shortcomings. Solution 1 will lost time (must checking first)
and solution 2 will throw a SQLException, and from the Exception, I do not know
how can I infer it is a primary key conflicting exception.
(I do not know how to distinguish it from other type of SQLException, for example,
database name error exception or SQL statement syntax error).
I do not know whether I have made myself understood.
Who have better solutions?
Thanks in advance,
GeorgeIf I use solution 2, can I get some information from
SQLException? For example, can the exception tell me
whether it is a duplicated primary key error or SQL
statememt syntax error? You don't have to look at the error text. You should
look at the error code. But keep in mind that
it is vendor specific. A duplicate key error in Oracle
has different error code then in SQL Server.Sounds good in theory, in practice it leaves a lot to be desired. First one still has to figure out which codes are problematic, and there is still no guarantee that they won't change. Moreover you might find that the code is used for different types of errors, and that won't work.
>
May you can have a look at the sqlstate, this should
be the same across different DB's as it is defined int
he SQL92 standard, but I wouldn't bet on it...
I would bet - against it. -
Is it possible to add records to tables using Enterprise Manager?
Can we add records to tables using Oracle Enterprise Manager web interface instead of the sqlplus commands ? if not, is there any easy way to insert data into table using a graphical interface?
You may consider using iSQL*Plus.
Check http://www.oracle.com/technology/obe/obe10gdb/install/isqlplus/isqlplus.htm
Thanks, -
How can i open a DOC or TXT file and insert the data into table?
How can i open a DOC or TXT file and insert the data into table?
I have a doc file . the doc include some columns and some rows.(for example 'ID,Name,Date,...').
I'd like open DOC file and I'd like insert them into the table with same columns.
Thanks.Use the SQL*Loader utility or the UTL_FILE package.
-
How to select data from 3rd row of Excel to insert into Sql server table using ssis
Hi,
Iam having Excel files with headers in first two rows , i want two skip that two rows and select data from 3rd row to insert into Sql Server table using ssis.3rd row is having column names.CUSTOMER DETAILS
REGION
COL1 COL2 COL3 COL4 COL5 COL6 COL7
COL8 COL9 COL10 COL11
1 XXX yyyy zzzz
2 XXX yyyy zzzzz
3 XXX yyyy zzzzz
4 XXX yyyy zzzzz
First two rows having cells merged and with headings in excel , i want two skip the first two rows and select the data from 3rd row and insert into sql server using ssis
Set range within Excel command as per below
See
http://www.joellipman.com/articles/microsoft/sql-server/ssis/646-ssis-skip-rows-in-excel-source-file.html
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Inserting multiple records to table in web dynpro
I am inserted single record in table created in web
dynpro view. If i insert the second record then the
first record has been overwritten. How to display
all rows that i was inserted without overwritting..
Can any one send me the coding???method ONACTIONINSERT .
*getting inputs
DATA lo_nd_district TYPE REF TO if_wd_context_node.
DATA lo_el_district TYPE REF TO if_wd_context_element.
DATA ls_district TYPE wd_this->element_district.
DATA lv_district_txt LIKE ls_district-district_txt.
navigate from <CONTEXT> to <DISTRICT> via lead selection
lo_nd_district = wd_context->get_child_node( name = wd_this->wdctx_district ).
get element via lead selection
lo_el_district = lo_nd_district->get_element( ).
get single attribute
lo_el_district->get_attribute(
EXPORTING
name = `DISTRICT_TXT`
IMPORTING
value = lv_district_txt ).
*inserting into table
DATA lo_nd_table TYPE REF TO if_wd_context_node.
DATA lo_el_table TYPE REF TO if_wd_context_element.
DATA ls_table TYPE wd_this->element_table.
DATA lv_name LIKE ls_table-name.
navigate from <CONTEXT> to <TABLE> via lead selection
lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
get element via lead selection
lo_el_table = lo_nd_table->get_element( ).
get single attribute
lo_el_table->set_attribute(
EXPORTING
name = `NAME`
" IMPORTING
value = lv_name_txt )."lv_name
*LIKEWISE I INSERTED AGE COLUMN TOO. -
Error - Unable to lock the record.
Error - Unable to lock the record. Cause: The record is being modified by another user.
Hi all,
I encountered the error above after deleting a record from a table then clicking the next button(train). Please help.
Thanks.
Maevethe two most probable possible reasons for this error:
1)When your program tried to delete the partiular record, somebody from back-end has deleted the record.
2)Your program is not commiting after doing the transaction.
Also,Check out this thread :
Re: save button - Unable to perform transaction on the record. stale data,
--Mukul -
How to find out the Non Partitioned Tables used 2Gb on oracle
Hi team
how to find out the Non Partitioned Tables used > 2Gb on oracle where not is sys & system
regardsheres 1 I made earlier
set pagesize 999
set linesize 132
col owner format a25
col segment_name format a60
select owner,segment_name,segment_type,(bytes/1024/1024)"MB size"
from dba_segments
where owner not in ('SYS','SYSTEM','XDB','MDSYS','SYSMAN') -- edit for taste
and segment_type = 'TABLE'
having (bytes/1024/1024) > 2000
group by bytes, segment_Type, segment_name, owner
order by 4 asc
Maybe you are looking for
-
Create accessible pdf from html page
Hello, I am trying to create a 508 compliant Pdf from a simple HTML page using the HTML to Pdf feature in Livecycle ES4 server. I was able to configure the service to generate tabbed Pdf, but the created Pdf has multiple accessibility issues. Some of
-
Parsing XML stored in CLOB (PL/SQL)
Hello, I would like to parse XML document like the example below. When it is stored in VARCHAR2 column, parsing works well. When it is stored in CLOB column, I get error message: "ORA-20100: Error occurred while parsing: Invalid char in text." The <t
-
EP (AS Java ) is taking time more Time to comeup
Hi Experts, We Have Implemented EP (AS JAVA). When we start the system it is taking more than 90 minutes to startup. Our Database is IBM DB2.we are having 2 EP instances in the same Database (MCOD) in which only one is in use. kindly can any one te
-
Minimized & Close buttons don't work !!!
hallooooo when i click on the button of minimized while another form is runing ,,, it don't work !! and return to the normal mode !!!! note ,, i make the minimized allowed (yes)..... & the close button don't work too !! what can i make to make them w
-
Please see the annexed image(my laptop Desktop Skin Shoot)
Hi Dear all Today to showing this message from windows in my laptop HP Pavilion g7...... i am not clear about this message, what i need to do Please suggest me, it's urgent