Duplicate record check before inserting records
Hi All
I want to show an user friendly message instead of (oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key oracle.jbo.Key). So in my EO i have written the following code:
OADBTransaction transaction = getOADBTransaction();
Object[] empNumberKey = {value};
EntityDefImpl empDefinition =
XXXXempEOImpl.getDefinitionObject();
XXXXempEOImpl empNo=
(XXXXempEOImpl)empDefinition.findByPrimaryKey(transaction,
new Key(empNumberKey));
if (empNo != null) {
throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(),
getPrimaryKey(), "CompanyNumber",
value, "AK",
"FWK_TBX_T_EMP_ID_UNIQUE");
setAttributeInternal(COMPANYNUMBER, value);
My observation is when duplicate empNumber is passed as '0011' then the error message is not thrown.But if i pass duplicate empNumber like '5411' error is thrown. So does it mean new Key(empNumberKey)) chops off leading 0's. Please note that in database the values are stored as '0011'. Pleasre advice. The validation fails only when value is having leading 0's.
You need to create a select command before Insert and check for the result returned after executing ExecuteScalar, this will return the records count to decide whether to insert or not,
Check the below example:
http://stackoverflow.com/questions/15320544/how-to-check-if-record-exists-if-not-insert-using-vb-net
Fouad Roumieh
Similar Messages
-
How to delete the Table Contents before inserting records into SQL table ?
Hello Experts,
I have a scenario where in I have to Pick up some records from SAP RFC & insert into SQL table.
i know how to do this scenario but the proble with this is before inserting we first have to ZAP the SQL table & insert a new records. One more twist is The Triggering is happening from SAP side with Sender RFC. If this would have been from SQL Side i could have written a Stored Procedure/ Trigger & could have called this before the SENDER JDBC communciation channel picks up the Triggering event from SQL side.
So how to do this scenarioin XI, First deleting all the Records of SQL table & then inserting the new reocrds. without using the BPM.
Regards,
Umeshhi umesh,
you can achieve this by writing SQL query in message mapping level..
refer this link:
http://help.sap.com/saphelp_nw04/helpdata/en/b0/676b3c255b1475e10000000a114084/frameset.htm
regards. -
Condition check befor exporting records
Can we put any condition before the records get exported.
I.e as the records reach syndication manager for syndication i want a condition to be executed and then based on the result of condition i want syndication map to be selected
Ex:-
if acount group=zind i want syndication map CREMDM04 to be exceuted
els i want CREMDM04_FI map to be executed.
Can i at any place check this,whether in workflow or somewhere but b4 syndicating.
Plz reply me
Regards
LakshmiHi Shifali,
It is like , since you are using conditional Validation you should use the Branch step instead of the individual Validation step firstly.
You can have your set of 20 Validations as designed which will be applicable to all the records.
Create 2 sets of this group Validations so say you have
- Group1_Validations
- Group2_Validations
The Group1_Validations will have all the common validations and along with that the Acct group validation also which, will check if the account group of the particular record is ZIND.
The Group2_Validations will have all the common validations and along with that the Acct group validation also which, will check if the account group of the particular record is ZMIS.
So all the records which will fulfill all the common validations and have acct group as ZIND will move in one path
and the other records having acct group ZMIS will take the default path.
For the records taking the first path you can hav ethe syndicate step which will save the desired CREMDM04 port
and the deafult records will go to the other syndicate where that port will have CREMDM04_Fi deatils in the map.
So accordingly your records will get routed.
Your workflow will look like this
/Syndicate1-----Stop
Start-Process>Branch----<
/Syndicate2-----Stop
Branch will have 2 Validtion groups
Group1_Validations- Syndicate1
Group2_Validations- Syndicate2
Syndicate 1 will have port storing all the necessary settings that match CREMDM04 map
and Syndicate 2 will have the port storing all the necessary settings that match CREMDM04_FI map
You can have a glance on the below links to get a betetr idea:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60f28084-b90e-2b10-3eb6-d6565367048a (LOOP in Workflows-Approvals)
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9180cbaf-0801-0010-f882-f2af6dc975d0 (Dynamism in mdm workflows)
Hope It Helped
Thanks & Regards
Simona Pinto -
UNIQUE constraint vs checking before INSERT
I have a SQL server table RealEstate with columns - Id, Property, Property_Value. This table has about 5-10 million rows and can increase even more in the future. I want to insert a row only if a combination of Id, Property, Property_Value does not exist
in this table.
Example Table -
1,Rooms,5
1,Bath,2
1,Address,New York
2,Rooms,2
2,Bath,1
2,Address,Miami
Inserting 2,Address,Miami should NOT be allowed. But, 2,Price,2billion is okay. I am curious to know which is the "best" way to do this and
why. The why part is most important to me.
Check if a row exists before you insert it.
Set unique constraints on all 3 columns and let the database do the checking for you.
Is there any scenario where one would be better than the other ?
Thanks.Why?
Because the database engine does exactly what you want - it is designed to do this in a way that anticipates collisions with simultaneous inserts and allows only a single row for any given combination of values. If you choose to manage this at the
application level - which is the alternative you propose - then EVERY application that attempts to insert rows must be designed to both check immediately before insertion and immediately afterwards (since these inserts can occur simulateously and you must
allow for communication delays between database and client). And since we know that programmers are not infallible (many other adjectives come to mind as well), there exists a high probability that the duplicate checking logic will fail. And do
not forget that there are many ways of inserting data into the table - it is not just your front-end application that must use this logic - it is also every other application that is used to manage data (such as SSMS, SSIS, bcp, etc.) -
Help with Update if record exists else insert record "upsert"
Hi Friends,
i have this table:
CREATE
TABLE TB_GEN_COMPANY
"ID_COMPANY" NUMBER NOT NULL ENABLE,
"COD_CODIGO" VARCHAR2(10 BYTE) NOT NULL ENABLE,
"DES_NAME" VARCHAR2(64 BYTE) NOT NULL ENABLE,
"DES_DIRECTION" VARCHAR2(128 BYTE) NOT NULL ENABLE,
"COD_RUC" CHAR(11 BYTE) NOT NULL ENABLE,
"FLG_EST" CHAR(1 BYTE) NOT NULL ENABLE,
"COD_USR_CR" VARCHAR2(16 BYTE) NOT NULL ENABLE,
"FCH_FEC_CR" TIMESTAMP (6) NOT NULL ENABLE,
"COD_USR_MOD" VARCHAR2(16 BYTE) NOT NULL ENABLE,
"FCH_FEC_MOD" TIMESTAMP (6) NOT NULL ENABLE,
CONSTRAINT "TB_GEN_COMPANIA_ESTADO_CHK" CHECK (FLG_ESTADO IN ('A', 'I'))
CONSTRAINT "TB_GEN_COMPANIA_PK" PRIMARY KEY ("ID_COMPANIA")
)I want to validate the code (cod_codigo). if the record exists, i will have to update with the news inputs parameters, otherwise it should create a new one i mean, an Insert.
Thanks for t he help.
Sorry for bad engl.i have this:
DECLARE
strCod_Compania VARCHAR2(10):='123';
strdes_Nombre VARCHAR2(64):='compname';
strdes_Direccion VARCHAR2(128):='calle las 123 santa beatriz';
strCod_CompaniaRuc VARCHAR2(11):='12345678911';
BEGIN
MERGE INTO TB_GEN_COMPANIA e
USING
TB_GEN_COMPANIA d
ON (e.cod_codigo=strCod_Compania)
WHEN MATCHED THEN
UPDATE
SET e.DES_NOMBRE=strdes_Nombre,
e.DES_DIRECCION=strdes_Direccion,
e.COD_RUC=strCod_CompaniaRuc,
e.FLG_ESTADO='A'
WHEN NOT MATCHED THEN
INSERT (COD_CODIGO,
DES_NOMBRE,
DES_DIRECCION,
COD_RUC,
FLG_ESTADO,
COD_USR_CREA,
FCH_FEC_CREA,
COD_USR_MOD,
FCH_FEC_MOD)
VALUES
(strCod_Compania,
strdes_Nombre,
strdes_Direccion,
strCod_CompaniaRuc,
'A',
'rmolina',
SYSDATE(),
'rmolina2',
SYSDATE());
END;
/this is my table:
CREATE TABLE "TB_GEN_COMPANIA"
( "COD_CODIGO" VARCHAR2(10 BYTE),
"DES_NOMBRE" VARCHAR2(64 BYTE),
"DES_DIRECCION" VARCHAR2(128 BYTE),
"COD_RUC" CHAR(11 BYTE),
"FLG_ESTADO" CHAR(1 BYTE),
"COD_USR_CREA" VARCHAR2(16 BYTE),
"FCH_FEC_CREA" TIMESTAMP (6),
"COD_USR_MOD" VARCHAR2(16 BYTE),
"FCH_FEC_MOD" TIMESTAMP (6)
)OK, when i execute the first query, 4 records are inserted in my table, and i don't know why,
any idea to solve this please?
Thanks -
Pre Flight Record Check List Alesis Firewire, Creative Sound Card, Adobe Audition
I was having many crashes on my computer, Windows Vista, so I made a check list to put a stop to all the crashes. This is what has worked for me I hope it works to you. Just so you all know since the recording I do is for the church radio shows that we produce. We start and end with a prayer. God Bless
Pre Flight Record Check List: To RECORD
Disconnect all Periphials
Reboot: Computer
Printer: OFF (not connected to recording copmptuer)
Speakers: All OFF
Closet Light: OFF
Cell Phones: OFF
Lockdown Internet
Disable Firewall
Computer Volume Settings: Alesis Microphone
2 Ch, 16 Bit, 44,100 Hz Cd Quality
* Do not allow applications to take control
Level- 100
Alesis Control Panel
Sample Rate: 44.1 Khz
Buffer 256
Rate: Any
System Sound: enable
System Latency: High
Open Adobe Software: Multitrack View
Adobe Audio Hardware Setup
Edit View: Alesis 44,100 Hz, Buffer Size: 256
Multimix View: Creative
Surround Encoder: Creative
Adobe Multi Track:
Monitoring: External
Adobe Edit Mode: Record in this mode
Click New: for Settings
Sample Rate:44100
* Stereo
* 16 Bit
Alesis Multimix 12
Main Mix
x- Pressed
x-Not Pressed
Alt 3/4
x-Pressed
x-Not Pressed
x-Not Pressed
x-Not Pressed
Sound Check:
Level
Pot: 1
Pot: 3
Main Mix:
ALT: 3/4Alesis stuff is generally pretty good and the Alesis is correct in that it is generally accepted that the TI chips are better and it is good advice.
PCI-e firewire800 card at ARC...
http://www.arc.com.au/?IOFIREPCIE1394B
I paid a $104 AUS it is now $77.90 (go figure)
Unfortunately there is no image on the web site. Without pulling my PC out I'm pretty sure it has 2 outputs and 2 inputs but don't quote me on that.
You should be able to pick something like this up anywhere in the world pretty cheap.
If it was me I would say that it would be a small investment and worth it to see if you can get the Alesis stuff stabalised. -
Truncate Table before Insert--Performance
HI All,
This post is in focus of special requirement where a table is truncated before inserting records in the table.
Now, when a table is truncated the High Water Mark(HWK) is reset to lowest memory allocated for table in tablespace. After this, would insert with append can boost the performance of the insert query?
In simple insert query, the oracle engine consults the free list to look for free spaces.
But in insert with apppend, the engine starts above the HWM. And the argument is when truncate has been executes on table, would the freelist be used in simple insert.
I just need to know if there are any benefits of using append insert on truncated table or simple insert would be same in term of performance with respect to insert with append.
Regards
NitsHi,
if you don't need the data truncate the table. There is no negativ impact whether you are using an conventional path or a direct path insert.
If you use append less redo is written for the table if the table is in NOLOGGING mode, but redo is written for all indexes. I would recommand to create a full backup after that (if needed), because your table will not be recoverable after that (no REDO Information).
Dim -
Check duplicate data entry in multi record block,which is a mandatory field
Dear all,
I have a situation where i have to check duplicate data entry(on a particular field,which is a mandatory field,i.e. it cannot be skipped by user without entering value) while data key-in in a Multi Record block.
As for reference I have used a logic,such as
1>In a When-Validate-Record trigger of that block I am assigning the value of that current item in Table type variable(collection type)
as this trigger fire every time as soon as i leave that record,so its assigning the value of that current time.And this process continues
then
2>In a When-Validate-Item trigger of that corresponding item(i.e. the trigger is at item level) has been written,where it compares the value of that current item and the value stored in Table type variable(collection type) of When-Validate-Record trigger.If the current item value is matched with any value stored in Table type variable I am showing a message of ('Duplicate Record') following by raise_form_trigger failure
This code is working fine for checking duplicate value of that multi record field
The problem is that,if user enter the value in that field,and then goes to next field,enter value to that field and then press 'Enter Query 'icon,the bolth Validate trigger fires.As result first when-validate record fires,which stores that value,and then when-validate-item fires,as a result it shows duplicate record message
Please give me a meaningful logic or code for solving this problem
Any other logic to solve this problem is also welcome@Ammad Ahmed
first of all thanks .your logic worked,but still i have some little bit of problem,
now the requirement is a master detail form where both master and detail is multirecord ,where detail cannot have duplicate record,
such as..........
MASTER:--
A code
A1
A2
DETAIL:--
D code
d1
d2 <-valid as for master A1 , detail d1 ,d2 are not duplicate
d2 <--invalid as as for master A1 , detail d2 ,d2 are duplicate
validation rule: A Code –D Code combination is unique. The system will stop users from entering duplicate D Code for a A Code. Appropriate error message will be displayed.*
actually i am facing a typical problem,the same logic i have been applied in detail section ,its working fine when i am inserting new records.problem starts when i query,after query in ' a ' field say 2 records (i.e. which has been earlier saved) has been pasted,now if i insert a new record with the value exactly same with the already present value in the screen(i.e. value populated after query) its not showing duplicate.................could u tell me the reason?and help me out...............its urgent plzzzzzzzzz
Edited by: sushovan on Nov 22, 2010 4:34 AM
Edited by: sushovan on Nov 22, 2010 4:36 AM
Edited by: sushovan on Nov 22, 2010 8:58 AM -
Inserting records into Table with check table logic in place
I want to insert records into a table, and have the check table to not allow invalid entries. Is there a function out there that will allow this? I am currently using the insert statement and it is working except that it is not giving an error when the value does not exist in the check table for the particular fields.
INSERT INTO ZSD_XREF VALUES WA_XREF.
That is the basic statement I'm using ZSD_XREF has several fields one being the material number field tied to the check table which happens to be MAKT file. The insert statement is not validating the material numbers using the check table, or at least it is not giving an error. Any ideas?Paul,
Unfortunately, open SQL statements such as INSERT, UPDATE do not go through the check table logic as they directly hit the database layer. Check table checks are performed only if you go through application layer that is when you enter the same data through a screen.
You have to do the checks yourself.
Happy checking!!!
Srinivas -
How to search for a record before insert or update a table?
I need use user input collected to check to see if there is a record already existing, if yes, update the record, if not insert a new record.
I try to use the select command first to figure out if there is a record matching already:
String User;
String sql="select from OFA_WEB_REPORT where username=?"
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setString(1,User);
I did not see a method in ResultSet could help me to determine if the resultset is null or not?
Is there any better way to check to see if there is a matching record existing already?
Thank you in advanceReSultSet rs=pstmt.execute();
if(rs.next())
System.out.println("there is a record existing");
else
System.out.println("there is not a record existing");
another,pstmt.execute() return's Value never null. -
Retrive a record before the last inserted record
Hi,
I use simple select statement to retrive records where cola = 'Yes':
select * from tbl1
where cola = 'Yes';
The result gives me about 10 records with different date.
From the above result, I want to get the record right before the last inserted record according to the date field; which means I can not use MAX function (all I want just one record).
If I write a function to return a date and passes it back to the SELECT statement, I'll get a date for each record, which I don't want.
I know there's a way to do that in PL/SQL.
Plese help me.
pemselect * from (
select * from
(select * from (select * from (table> order by <date> desc) where rownum < 3)
order by <date>) where rownum =1 -
請求幫助,我有adobe正版軟體,但是序號不見了,有辦法查到之前的紀錄或求解決辦法嗎?
Request the help, I have the adobe the original software (Adobe Creative Suite 6 Design & Web Premium), but the ordinal number is missing, there is way checking before recording or begging the solution
Does anyone know how can I do? Please help,thank you very much.Hi there,
I'm not sure that I understand. Are you trying to find the order number or serial number for your Adobe software? If so, please see Find your serial number quickly - Adobe.
Best,
Sara -
Error while inserting record in Key-Flex Values Set interface
Guys
on 11.5.10.2
Actually the problem is being occurred while inserting value in Job Flex Field Value set, we have created two segment for job key flex filed, No and name, it was working fine, but since we have uploaded bulk data via api "fnd_flex_values_pkg.INSERT_ROW" which was around 100 off record, but after completion this task system is not taking new value by Values set interface, and show message "APPS-FND-01206: You entered duplicate values or sequence of value that must be unique for every record",
However, we insert the job number through api, it is inserting without error while
Interface is not taking value and raise duplicate message error,
which is APPS-FND-01206
Please Advice.Thanks for supporting dunacan
I have mentioned both of segment detail . please advice,
1.One is Job No segment
Segment1 number 10
Required Check Yes
Value set Info JOB_NO
List Type : List of Values
Security Type : No Security
Format Validation : select number 7,0 and check on number only (0-9)
Validation Type Independent
2.One is Job Name segment
Segment2 number 20
Required Check Yes
Value set Info JOB_NAME
List Type : List of Values
Security Type : No Security
Format Validation : select CHAR 60 Validation Type Independent
It was strange that how could it possible duplication value without having database,i am unable to find this issued,
Edited by: oracle0282 on Jan 17, 2011 3:32 AM -
Inserting records into a table with all caps
Hello
I have a procedure that inserts records into a table. How do I ensure that the text values inserted are recorded all capital letters into the table?
Thanks.You can use UPPER(..) function in your insert statement, so that values are converted to UPPER, before insert.
If you want to check at table level, you can achieve that by writting a before insert trigger and in that trigger check
IF UPPER(:new.<col>) != :new.<col> THEN
RAISE_APPLICATION_ERROR(-20101,'Error: Not all values are in upper case')
END IF; -
Inserting records in the table
Hi All,
I am working on a report where we are inserting huge numbers of records from an internal table to the ztable, I have been advised that rather than inserting all the records at one time we should divide the recods into small blocks may be let's say 100,000 of each block and try inserting the blocks in the ztable. So I was just wondering if anyone of you can help me with this how can I get this?
my internal table is it_data_table and my ztable is z_data_table.
Thanks,
RajeevHi,
Rather than inserting records from the workarea it is better if you use the inetrnal table for insertion. If youu have say 50025 records than it will hit the database that many times which definitely is a performance issue.If you have an internal table say 'it' and another internal table 'it_temp' with a similiar structure, you can try something like as follows
loop at it.
count = count + 1.
it_temp = it.
append it_temp.
if count = 10000.
insert ztable from table it_temp accepting duplicate keys. "to avoid a dump if there are duplicates count = 0.
refresh it_temp.
endif.
endloop.
if it_temp is not initial.
insert ztable from table it_temp accepting duplicate keys.
endif.
In the above code the loop will run the number of record times but, the insert statement will run only 50025/10000 times (i.e, 5 times). After the completion of the loop we need to add the remaining 25 records (because insert will work last inside the loop when 50000 records are reached), for that we will issue the insert statement after completion of the loop, after checking the it_temp table. So the total of 50025 records would be entered in a batch of 6 inserts rather than that many inserts if using just the workarea.
I hope this does help you in your issue.
Thanks and Regards,
Sachin.
Maybe you are looking for
-
Cannot capture, but can do pretty much everything else with deck. What now?
Hello everybody, I'm writing for the Gateway Media Center. We're basically a small group of students which handles anything video or TV related for a public school district, mainly the high school. Our main editing system (Mac connected to a MiniDV d
-
Agent Desktop Error When receive Incoming Call
Hi, I have CAD Ver 8.5.1.39 | CUCM Ver 8.5.1.10000-26 | UCCX Ver 8.5.1.10000-37 running on my network now. there some problem occurs when I put an Agent into the Line Group with Top Down Distribution call(actualy all the Distribution call t
-
OC4J_HOME and J2EE_HOME settings
hello, i use oracle 10g enterprise edition and oracle application server 10g. i am not able to view the demos in datasource named mvdemo. probably, my problem is classpath settings. i have to configure the classpath settings for OC4J_HOME and J2EE_HO
-
I installed oracle on my win2003 and had 2 db (orcl and ora7) and it worked fine before. However, the listener fail to start again when I rebooted my machine. Here is the message when I type start in the LSNTCTL prompt. TNS-12536 : TNS : operation wo
-
I want to know ...
Hello, In BW there are so many terminologies I want to understand, such as: 1.Fiscal year variant which always stick with fiscal year 2.Fiscal year period 3.Relationships between Fiscal year variant and Fiscal year 4.Relationships between Fiscal year