Duplicate rows in Record grp "Cust_sytem" in form "OKSITMSL"
Hi,
We are using Service contracts in Production environment.
Duplicate rows selected for LOV query.
By adding a line userenv('language') we solve the problem.
But the coding was written inside the standard "OKSITMSL.pll". Here For the Field "NAME", LOV
record group "CUST_SYSTEM" assigned dynamically based on
other fields "ITEMSEL.FILTER = SYSTEM" and "ITEMSEL.CUSTOMER_FILTER = CUSTOMER".
I have added piece of the details below.
Form is Standard form "OKSITMSL", Which is calling om parent form "OKSAUDET".
Form : OKSITMSL
Block : ITEMSEL
field : NAME
pll : OKSITMSL.pll
oksitmsl.pll coding-------------
ELSIF NAME_IN('ITEMSEL.FILTER') = 'System' THEN
If UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'CUSTOMER' then
l_group_name := 'CUST_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'RELATED' then
l_group_name := 'REL_CUST_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'BOTH' then
l_group_name := 'BOTH_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'ALL' then
l_group_name := 'OKS_SYSTEM';
End If;
Set_Lov_Property('ITEMSEL_LEVEL', GROUP_NAME, l_group_name);
âCUST_SYSTEMâ Record group present in âOKSITMSLâ form.
I need the advice how to solve my problem by adding a line in query of "CUST_SYSTEM" record group without touching/alter standard form.
Thanks in advance.
Navas
Of course you can/should do additional validations on the client as needed basing on your requirement, there is nothing wrong with that. If you can't afford the roundtrip to the database than by all means: do everything you can to permit it if it's not allowed anyway.
But even if you do checks on the client side you must not forget that you are in a multi user environment and you can't check for duplicates of uncommited data in another session. Also let's not forget that you might not be the only one jamming data into your database, and if you don't enforce it with a constraint another application actually could create duplicates because the developers forgot to implement a unique check. So the only way to be 100% sure you cannot pile duplicates into the database is a constraint.
My point is:
- always create a constraint when you want to enforce uniqueness => this is a must
- if needed do additional checkings on the client to make users life easier => optional and can be implemented as needed
From what I see mostly the first point get's ignored, and the second get's implemented. The implementations most of the time utterly fail when I start the application twice and enter the same data in two different sessions. Now I have a serious problem, as data which is supposed to be unique isn't unique anymore. too_many_rows are going to happen in every corner of the application, and nobody knows why.
cheers
Similar Messages
-
Restrict Duplicate entry of record before saving the form
Hi!!
I need to validate duplicate entry of ITEM CODE before saving the FORM. Which means, if I have entered an ITEM CODE in a row, the same ITEM CODE should not be allowed to be entered in any other rows. It should throw an error message and should ask to enter another ITEM CODE instead. I did not get the correct logic from the threads.
Regards
Mittohey i have a requirement that to restrict duplicate entry in both block(both multi record).the blocks are DEPT(MATER)
EMP(DETAIL)
the associated fieds in master block DEPT.DEPT_NO,in detail EMP.EMP_ID .
I have done' Kevin D Clarke’s calculated item ' both in master and detail block
its working fine for master block but in case of detail block its only respond to the current session(i.e. if the new value is inserted or save it will restrict another record to be inserted of that last record's value),it does not restrict duplicate value enter ,checking with other existing records(which are saved in earlier session,though after query it is shown on the form)
can anyone guide me why its not working -
How to modify query statement in record grp of LOV in standard form
Hi,
We are using Service contracts in Production environment.
Duplicate rows selected for LOV query.
By adding a line userenv('language') we solve the problem.
But the coding was written inside the standard "OKSITMSL.pll". Here For the Field "NAME", LOV
record group "CUST_SYSTEM" assigned dynamically based on
other fields "ITEMSEL.FILTER = SYSTEM" and "ITEMSEL.CUSTOMER_FILTER = CUSTOMER".
I have added piece of the details below.
Form is Standard form "OKSITMSL", Which is calling om parent form "OKSAUDET".
Form : OKSITMSL
Block : ITEMSEL
field : NAME
pll : OKSITMSL.pll
oksitmsl.pll coding-------------
ELSIF NAME_IN('ITEMSEL.FILTER') = 'System' THEN
If UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'CUSTOMER' then
l_group_name := 'CUST_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'RELATED' then
l_group_name := 'REL_CUST_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'BOTH' then
l_group_name := 'BOTH_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'ALL' then
l_group_name := 'OKS_SYSTEM';
End If;
Set_Lov_Property('ITEMSEL_LEVEL', GROUP_NAME, l_group_name);
âCUST_SYSTEMâ Record group present in âOKSITMSLâ form.
I need the advice how to solve my problem by adding a line in query of "CUST_SYSTEM" record group without touching/alter standard form.
Thanks in advance.
Navasthank you shadow,
I think you mean like below:
and trim(leading 0 from a.DD_DRX_BSID_NID) = nvl(trim(to_char(SUBSTR('00042',6,5),'XXXXXXXXX')),0)
and trim(leading 0 from a.DD_DRX_BSID_BSC) = nvl(trim(to_char(SUBSTR('00042',11,5),'XXXXXXXXX')),0) ))But i think it compares with all 0's record ... but that's not correct
Edited by: josh1612 on Dec 22, 2008 2:50 AM -
I have a master table and i need to import the rows into the parent and child table.
Master table name is Flatfile_Inventory
Parent Table name is INVENTORY
Child Tables name are INVENTORY_AMOUNT,INVENTORY_DETAILS,INVENTORY_VEHICLE,
Error details will be goes to LOG_INVENTORY_ERROR
I have 4 duplicate rows in the Flatfile_Inventory which i have already inserted in the Parent and child table.
Again when i run the query using stored procedure,
its tells that all the 4 rows are duplicate and will move to the Log_Inventory_Error.
I need is if i have the duplicate rows in the flatfile_Inventory when i start inserting into the parent and child table the already inserted row have the unique ID i
must identify it and delete that row in the both parent and chlid table.And latest row must get inserted into the Parent and child table from Flatfile_Inventory.
Please help me to write the query i have attached the Full stored procedure Script..
Arunraj KumarHi Santhosh,
This is my Script.
-- =============================================
-- Stored Procedure for FLATFILE_INVENTORY
-- =============================================
-- Drop stored procedure if it already exists
DROP PROCEDURE SP_Flatfile_Inventory
GO
CREATE PROCEDURE SP_Flatfile_Inventory
AS
--USE IconicMarketing
GO
DECLARE
@FileType varchar(50) ,
@ACDealerID varchar(50) ,
@ClientDealerID varchar(50) ,
@DMSType varchar(50) ,
@StockNumber varchar(50) ,
@InventoryDate datetime ,
@StockType varchar(100) ,
@DMSStatus varchar(50) ,
@InvoicePrice numeric(18, 2) ,
@CostPack varchar(50) ,
@SalesCost numeric(18, 2) ,
@HoldbackAmount numeric(18, 2) ,
@ListPrice numeric(18, 2) ,
@MSRP varchar(max) ,
@LotLocation varchar(50) ,
@TagLine varchar(max) ,
@Certification varchar(max) ,
@CertificationNumber varchar(max) ,
@VehicleVIN varchar(50) ,
@VehicleYear bigint ,
@VehicleMake varchar(50) ,
@VehicleModel varchar(50) ,
@VehicleModelCode varchar(50) ,
@VehicleTrim varchar(50) ,
@VehicleSubTrimLevel varchar(max) ,
@Classification varchar(max) ,
@TypeCode varchar(100) ,
@VehicleMileage bigint ,
@EngineCylinderCount bigint ,
@TransmissionType varchar(50) ,
@VehicleExteriorColor varchar(50) ,
@VehicleInteriorColor varchar(50) ,
@CreatedDate datetime ,
@LastModifiedDate datetime ,
@ModifiedFlag varchar(max) ,
@InteriorColorCode varchar(50) ,
@ExteriorColorCode varchar(50) ,
@PackageCode varchar(50) ,
@CodedCost varchar(50) ,
@Air varchar(100) ,
@OrderType varchar(max) ,
@AgeDays bigint ,
@OutstandingRO varchar(50) ,
@DlrAccessoryRetail varchar(50) ,
@DlrAccessoryCost varchar(max) ,
@DlrAccessoryDesc varchar(max) ,
@ModelDesc varchar(50) ,
@Memo1 varchar(1000) ,
@Memo2 varchar(max) ,
@Weight varchar(max) ,
@FloorPlan numeric(18, 2) ,
@Purchaser varchar(max) ,
@PurchasedFrom varchar(max) ,
@InternetPrice varchar(50) ,
@InventoryAcctDollar numeric(18, 2) ,
@VehicleType varchar(50) ,
@DealerAccessoryCode varchar(50) ,
@AllInventoryAcctDollar numeric(18, 2) ,
@BestPrice varchar(50) ,
@InStock bigint ,
@AccountingMake varchar(50) ,
@GasDiesel varchar(max) ,
@BookValue varchar(10) ,
@FactoryAccessoryDescription varchar(max) ,
@TotalReturn varchar(10) ,
@TotalCost varchar(10) ,
@SS varchar(max) ,
@VehicleBody varchar(max) ,
@StandardEquipment varchar(max) ,
@Account varchar(max) ,
@CalculatedPrice varchar(10) ,
@OriginalCost varchar(10) ,
@AccessoryCore varchar(10) ,
@OtherDollar varchar(10) ,
@PrimaryBookValue varchar(10) ,
@AmountDue varchar(10) ,
@LicenseFee varchar(10) ,
@ICompany varchar(max) ,
@InvenAcct varchar(max) ,
@Field23 varchar(max) ,
@Field24 varchar(max) ,
@SalesCode varchar(max) ,
@BaseRetail varchar(10) ,
@BaseInvAmt varchar(10) ,
@CommPrice varchar(10) ,
@Price1 varchar(10) ,
@Price2 varchar(10) ,
@StickerPrice varchar(10) ,
@TotInvAmt varchar(10) ,
@OptRetail varchar(max) ,
@OptInvAmt varchar(10) ,
@OptCost varchar(10) ,
@Options varchar(max) ,
@Category varchar(max) ,
@Description varchar(max) ,
@Engine varchar(max) ,
@ModelType varchar(max) ,
@FTCode varchar(max) ,
@Wholesale varchar(max) ,
@Retail varchar(max) ,
@Draft varchar(max) ,
@Inventoryid int;
DECLARE Inventory_Cursor CURSOR FOR
SELECT * from [dbo].[FLATFILE_INVENTORY];
OPEN Inventory_Cursor
FETCH NEXT FROM Inventory_Cursor
INTO @FileType ,
@ACDealerID ,
@ClientDealerID ,
@DMSType ,
@StockNumber ,
@InventoryDate ,
@StockType ,
@DMSStatus ,
@InvoicePrice ,
@CostPack ,
@SalesCost ,
@HoldbackAmount ,
@ListPrice ,
@MSRP ,
@LotLocation ,
@TagLine ,
@Certification ,
@CertificationNumber ,
@VehicleVIN ,
@VehicleYear ,
@VehicleMake ,
@VehicleModel ,
@VehicleModelCode ,
@VehicleTrim ,
@VehicleSubTrimLevel ,
@Classification ,
@TypeCode ,
@VehicleMileage ,
@EngineCylinderCount ,
@TransmissionType ,
@VehicleExteriorColor ,
@VehicleInteriorColor ,
@CreatedDate ,
@LastModifiedDate ,
@ModifiedFlag ,
@InteriorColorCode ,
@ExteriorColorCode ,
@PackageCode ,
@CodedCost ,
@Air ,
@OrderType ,
@AgeDays ,
@OutstandingRO ,
@DlrAccessoryRetail ,
@DlrAccessoryCost ,
@DlrAccessoryDesc ,
@ModelDesc ,
@Memo1 ,
@Memo2 ,
@Weight ,
@FloorPlan ,
@Purchaser ,
@PurchasedFrom ,
@InternetPrice ,
@InventoryAcctDollar ,
@VehicleType ,
@DealerAccessoryCode ,
@AllInventoryAcctDollar ,
@BestPrice ,
@InStock ,
@AccountingMake ,
@GasDiesel ,
@BookValue ,
@FactoryAccessoryDescription ,
@TotalReturn ,
@TotalCost ,
@SS ,
@VehicleBody ,
@StandardEquipment ,
@Account ,
@CalculatedPrice ,
@OriginalCost ,
@AccessoryCore ,
@OtherDollar ,
@PrimaryBookValue ,
@AmountDue ,
@LicenseFee ,
@ICompany ,
@InvenAcct ,
@Field23 ,
@Field24 ,
@SalesCode ,
@BaseRetail ,
@BaseInvAmt ,
@CommPrice ,
@Price1 ,
@Price2 ,
@StickerPrice ,
@TotInvAmt ,
@OptRetail ,
@OptInvAmt ,
@OptCost ,
@Options ,
@Category ,
@Description ,
@Engine ,
@ModelType ,
@FTCode ,
@Wholesale ,
@Retail ,
@Draft ;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @VehicleVIN ;
-- ****************** insert into Inventory Table ***********
INSERT INTO INVENTORY
IconicDealerID,
StockNumber,
DMSType,
InventoryDate
VALUES (@ClientDealerID,@StockNumber,@DMSType,@InventoryDate);
set @Inventoryid = scope_identity();
PRINT @Inventoryid;
--Insert into Inventory_Details Table
INSERT INTO [INVENTORY_DETAILS]
InventoryID,
StockType,
DMSStatus,
LotLocation,
TagLine,
Certification,
CertificationNumber,
CreatedDate,
LastModifiedDate,
ModifiedFlag,
PackageCode,
OrderType,
AgeDays,
OutstandingRO,
Memo1,
Memo2,
Purchaser,
PurchasedFrom,
DealerAccessoryCode,
InStock,
AccountingMake,
SS,
Account,
AccessoryCore,
ICompany,
InvenAcct,
Field23,
Field24,
SalesCode,
Draft,
FTCode
VALUES (
@InventoryID,
@StockType,
@DMSStatus,
@LotLocation,
@TagLine,
@Certification,
@CertificationNumber,
@CreatedDate,
@LastModifiedDate,
@ModifiedFlag,
@PackageCode,
@OrderType,
@AgeDays,
@OutstandingRO,
@Memo1,
@Memo2,
@Purchaser,
@PurchasedFrom,
@DealerAccessoryCode,
@InStock,
@AccountingMake,
@SS,
@Account,
@AccessoryCore,
@ICompany,
@InvenAcct,
@Field23,
@Field24,
@SalesCode,
@Draft,
@FTCode
--Insert into Inventory_Amount Table
INSERT INTO [dbo].[INVENTORY_AMOUNT]
InventoryID,
AllInventoryAcctDollar,
OtherDollar,
PrimaryBookValue,
AmountDue,
LicenseFee,
CalculatedPrice,
OriginalCost,
BookValue,
TotalReturn,
TotalCost,
DlrAccessoryRetail,
DlrAccessoryCost,
DlrAccessoryDesc,
InternetPrice,
InventoryAcctDollar,
BestPrice,
Weight,
FloorPlan,
CodedCost,
InvoicePrice,
CostPack,
SalesCost,
HoldbackAmount,
ListPrice,
MSRP,
BaseRetail,
BaseInvAmt,
CommPrice,
Price1,
Price2,
StickerPrice,
TotInvAmt,
OptRetail,
OptInvAmt,
OptCost,
Wholesale,
Retail
VALUES (
@InventoryID,
@AllInventoryAcctDollar,
@OtherDollar,
@PrimaryBookValue,
@AmountDue,
@LicenseFee,
@CalculatedPrice,
@OriginalCost,
@BookValue,
@TotalReturn,
@TotalCost,
@DlrAccessoryRetail,
@DlrAccessoryCost,
@DlrAccessoryDesc,
@InternetPrice,
@InventoryAcctDollar,
@BestPrice,
@Weight,
@FloorPlan,
@CodedCost,
@InvoicePrice,
@CostPack,
@SalesCost,
@HoldbackAmount,
@ListPrice,
@MSRP,
@BaseRetail,
@BaseInvAmt,
@CommPrice,
@Price1,
@Price2,
@StickerPrice,
@TotInvAmt,
@OptRetail,
@OptInvAmt,
@OptCost,
@Wholesale,
@Retail
--Insert into Inventory_Vehicle Table
INSERT INTO [dbo].[INVENTORY_VEHICLE]
InventoryID,
InteriorColorCode,
ExteriorColorCode,
Air,
ModelDesc,
VehicleType,
VehicleVIN,
VehicleYear,
VehicleMake,
VehicleModel,
VehicleModelCode,
VehicleTrim,
VehicleSubTrimLevel,
Classification,
TypeCode,
VehicleMileage
VALUES (
@InventoryID,
@InteriorColorCode,
@ExteriorColorCode,
@Air,
@ModelDesc,
@VehicleType,
@VehicleVIN,
@VehicleYear,
@VehicleMake,
@VehicleModel,
@VehicleModelCode,
@VehicleTrim,
@VehicleSubTrimLevel,
@Classification,
@TypeCode,
@VehicleMileage
-- Move cursor to Next record
FETCH NEXT FROM Inventory_Cursor
INTO @FileType ,
@ACDealerID ,
@ClientDealerID ,
@DMSType ,
@StockNumber ,
@InventoryDate ,
@StockType ,
@DMSStatus ,
@InvoicePrice ,
@CostPack ,
@SalesCost ,
@HoldbackAmount ,
@ListPrice ,
@MSRP ,
@LotLocation ,
@TagLine ,
@Certification ,
@CertificationNumber ,
@VehicleVIN ,
@VehicleYear ,
@VehicleMake ,
@VehicleModel ,
@VehicleModelCode ,
@VehicleTrim ,
@VehicleSubTrimLevel ,
@Classification ,
@TypeCode ,
@VehicleMileage ,
@EngineCylinderCount ,
@TransmissionType ,
@VehicleExteriorColor ,
@VehicleInteriorColor ,
@CreatedDate ,
@LastModifiedDate ,
@ModifiedFlag ,
@InteriorColorCode ,
@ExteriorColorCode ,
@PackageCode ,
@CodedCost ,
@Air ,
@OrderType ,
@AgeDays ,
@OutstandingRO ,
@DlrAccessoryRetail ,
@DlrAccessoryCost ,
@DlrAccessoryDesc ,
@ModelDesc ,
@Memo1 ,
@Memo2 ,
@Weight ,
@FloorPlan ,
@Purchaser ,
@PurchasedFrom ,
@InternetPrice ,
@InventoryAcctDollar ,
@VehicleType ,
@DealerAccessoryCode ,
@AllInventoryAcctDollar ,
@BestPrice ,
@InStock ,
@AccountingMake ,
@GasDiesel ,
@BookValue ,
@FactoryAccessoryDescription ,
@TotalReturn ,
@TotalCost ,
@SS ,
@VehicleBody ,
@StandardEquipment ,
@Account ,
@CalculatedPrice ,
@OriginalCost ,
@AccessoryCore ,
@OtherDollar ,
@PrimaryBookValue ,
@AmountDue ,
@LicenseFee ,
@ICompany ,
@InvenAcct ,
@Field23 ,
@Field24 ,
@SalesCode ,
@BaseRetail ,
@BaseInvAmt ,
@CommPrice ,
@Price1 ,
@Price2 ,
@StickerPrice ,
@TotInvAmt ,
@OptRetail ,
@OptInvAmt ,
@OptCost ,
@Options ,
@Category ,
@Description ,
@Engine ,
@ModelType ,
@FTCode ,
@Wholesale ,
@Retail ,
@Draft ;
END
CLOSE Inventory_Cursor;
DEALLOCATE Inventory_Cursor;
GO
SET ANSI_PADDING OFF
GO
Arunraj Kumar -
How to select a row from duplicate set of records?
I want to select a row from a duplicate set of records.
below is the explanation of my requirement.
select * from test_dup;
COL_BILL COL_SERV COL_SYS
b1 s1 c
b1 s1 g
b1 s2 c
b1 s2 g
b2 s2 g
b2 s3 c
b2 s3 g
b3 s3 c
Here what I want is, for a distinct col_sys if col_bill and col_serv is same then I need the row where col_sys='c'
from the above result set I need the following:
b1 s1 c
b1 s2 c
b2 s3 c
I am using the following SQL query which is giving me the correct result set. But it will hamper the performance because there are total 45 columns in the table and total volume is around 50 million.
select * from test_dup where col_bill||col_serv in (
select col_bill||col_serv from (
select col_bill,col_serv,count(*) from test_dup
where col_sys in ('c','g')
group by col_bill,col_serv having count(*) >1)) and
col_sys='c';
Can anyone please provide me the optimize SQL query for the same.Hi,
Another way,
SQL> with test_dup
as
select 'b1' col_bill, 's1' col_serv, 'c' col_sys from dual union all
select 'b1', 's1', 'g' from dual union all
select 'b1', 's2', 'c' from dual union all
select 'b1', 's2', 'g' from dual union all
select 'b2', 's2', 'g' from dual union all
select 'b2', 's3', 'c' from dual union all
select 'b2', 's3', 'g' from dual union all
select 'b3', 's3', 'c' from dual
select col_bill, col_serv, min(col_sys) col_sys
from test_dup
where col_sys in ('c', 'g')
group by col_bill, col_serv
having count( * ) > 1
and count(nullif(col_sys, 'g')) > 0;
CO CO C
b1 s1 c
b2 s3 c
b1 s2 c
3 rows selected.Regards
Peter
Edited by: Peter on Feb 18, 2009 1:10 AM
- Added test data, thanks Karthick -
Using JHS 'Duplicate Row' Feature In Form
I am having a minor set back in implementing the JHeadstart duplicateRow() method in a Form (opposed to the default Table-view).
In table-view the duplicateRow() method of the JhsCollectionModel works flawlessly with items that are set to Update Allowed?: while_new. When we use the method in a Form view however, items remain non-updateable after the Duplicate Row button has be pressed. This prevent rows from being copied within the given Form view page.
I do not understand how this is occuring since row.setNewRowState(Row.STATUS_NEW) is being called within the duplicateRow() method. Is another object (other than oracle.jbo.Row) that needs to be used in Form view instead of Table view in order to perform this functionality?
ThanksWell, after an entire day of playing around, I was finally able to get a proper call to the onCreate() method. I figure out that I could make a hard-coded call to:
oracle.binding.OperationBinding opBinding = getBindings().getOperationBinding("CreateCampus"); ...to get a OperationBinding interface to a FacesCtrlActionBinding (which extends JUCtrlActionBinding). With a simple cast, this allowed me to make a call to JhsPageLifecycle.onCreate().
Unfortunately, when the rest of my algorithm runs, it's not "copying" over any of the non-PK row values (as it normally does before I implemented this logic).
So to simplify things: Has anyone ever coded a simple single-row copying ADF Faces/ADF BC feature before that would work in both Table and Form views? Or, how easily could the JHeadstart duplicateRow() feature be extended to work in Form-view?
If I can see how a simple shallow copy is supposed to operate within the use of JHeadstart, I think I can extend it for our "deep copying' requirement.
Thanks. -
Remove the duplicate rows but keep the most recent and oldest records
I have a Product table, some products have duplicate rows(same productID). I want to keep the most recent and the oldest records based on ETL load date (or min and max productKey), delete others. How to do this in a simple way?
ProductKey | ProductID |ETL_Load_Date
1001 | 501 | 2014-01-01
1002 | 501 | 2014-01-02
1003 | 501 | 2014-01-03
1011 | 502 | 2014-01-01
1012 | 502 | 2014-01-02
1013 | 502 | 2014-01-03declare @table table (ProductKey int, ProductID int, ETL_Load_Date date)
insert @table (ProductKey, ProductID, ETL_Load_Date)
values
( 1001 , 501 , '2014-01-01' ), ( 1002 , 501 , '2014-01-02' ),
( 1003 , 501 , '2014-01-03' ), ( 1011 , 502 , '2014-01-01' ),
( 1012 , 502 , '2014-01-02' ), ( 1013 , 502 , '2014-01-03' )
SELECT *
FROM @table t
INNER JOIN (
SELECT MIN(etl_load_date) min_load_date, MAX(etl_load_date) max_load_date, ProductID
FROM @table
GROUP BY ProductID
) m
ON t.ProductID = m.ProductID
AND t.ETL_Load_Date IN (min_load_date,max_load_date)
This will show both the min and max load dates, for each ProductID
Thanks to Saeid for posting some test objects. -
Report Builder 2.0 returning duplicate rows in query designer
Hi,
I have a query running off a model, when I explore the data in the model and in a standard sql table it returns one row for each record, which include a unique id for each which is correct.
When I go into report builder query designer, it shows duplicate rows for each record. I have removed and added fields to try and pin point why and the only reason i can come up with is that it runs fine until I add in a field thats varchar(255) or
varchar(max). This is when it starts to duplicate the records.
Can anyone tell me why it does this or point me in the direction of how to stop this. I can't edit the query in text to add DISTINCT so thats not an option.
Many thanks,
JJSJOK - I have found a partial answer. By Googling Report Builder and VARCHAR, I found another post which reported problems with the semantic query builder when the underlying table/view was returning columns of type VARCHAR(MAX).
On looking at the length setting for the data column in the DSV, this reported a length of 2,147,483,647 for this field. This is very odd because on querying the underlying table the largest length that I can find for this column is 191,086
(which is far larger than I would have expected - I am investigating this separately).
However, why should the Report Model think that this field contains such a large value?
Anyway, the other post that I found reported that they had solved their problem by converting the field to a VARCHAR (255). I tried this (by casting the column in my View to VARCHAR(255)) and this resolved the problem
- no more duplicate rows when adding this field to the query!!!
I also tried CASTING to TEXT and to VARCHAR(8000). The former did not resolve the problem; the latter did.
So I have a workaround but I don't understand why.
Can anybody explain why having a VARCHAR(max) column in my entity causes duplicate rows.
I suspect it is to do with the fact that for some reason the Report Model seems to think that there is an exceptionally long text string stored in this column in one of the rows but that again is a puzzle.
Thanks
Richard -
How can i find Duplicate Rows in forms6i
Hi,
How can i find duplicate rows in multiple record in forms6i.
Thanks
Raghu.KOops, sorry for misreading your question. (However the SQL I gave you above is also very handy, and worth saving.)
Okay, this is off the top of my head and untested, but might just work. Assuming that your data block name is MYBLOCK, and that the item that you want to check for dups on is named MYNUM, create an item-level WHEN-VALIDATE-ITEM trigger with the following code.
declare
l_newest_record number(10) := :system.cursor_record;
l_newest_mynum number(10) := :myblock.mynum;
l_dup_found boolean := false;
begin
-- In this loop, we skip backwards through all new records to look for dups.
while :system.cursor_record > 1 loop
previous_record;
if :system.record_status = 'NEW' then
if :myblock.mynum := l_newest_mynum then
l_dup_found := true;
exit; -- Dup found!
end if;
else
exit; -- We've gone backwards past the first new record.
end if;
end loop;
-- In this loop, we return to the current record.
while :system.cursor_record < l_newest_record loop
next_record;
end loop;
if l_dup_found then
raise duplicate_row_found; -- user-defined exception
end if;
end;
The above code only checks for dups in the new form records. It assumes that a unique constraint in the database will deal with records actually committed.
Armand -
How to delete duplicate rows in oracle and retaining last duplicate rows
Hi,
I'm having millions of records in the table .Some duplicate values/rows are inserted in it.
I just want to delete duplicate rows but also want to retain the last duplicate row.
For eg if one record is found three times ,i want to delete first and second record and retain
the third one i.e the last inserted one.
Regards
Paramdeep Singhuser13310594 wrote:
Hi,
I'm having millions of records in the table .Some duplicate values/rows are inserted in it.
I just want to delete duplicate rows but also want to retain the last duplicate row.
For eg if one record is found three times ,i want to delete first and second record and retain
the third one i.e the last inserted one.Hi Paramdeep,
To start with, since you do not wish to keep multiple rows with same values, why allow them to get inserted in the first place?
Wouldn't it be easier to block duplicate rows from inserting by creating a Unique constraint on Column(s) that define a row as duplicate, then rather deleting duplicate rows periodically?
For deleting duplicate rows, there are N number of techniques available. Always remember, you need to have a rigid criteria that marks row as duplicate.
[url http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:15258974323143]this is one recomended by tom for large tables.
Vivek L -
How to get duplicate rows in a large table
I have a table which consists of 26 columns and 2 milion records..while doing validation i suspect there are duplicate records in that table...
Is there any way to check duplicate rows in a table?I went through link..in all the messages query is for 2 or 3 columns...but my scenario is i have 26 columns ...and i suspect there is duplicate row inserting .for which value is same for all 26 columns .how should i do .?
do i need to do group by all 26 columns and do having count(*) ...26 times? -
Display and edit currently selected row of ADF Table in ADF Form
I have an ADF Read-only Table and ADF Form, which were created from the same Data Control.
I need to be able to edit the selected row of the table in the form (just like in "Binding Data Controls to your JSF page" part of "Developing RIA Web Applications with Oracle ADF" Tutorial). However, I can't figure out how to do this :(
I found the following solution on the Web: #{bindings.DeptView1.currentRow.dataProvider.dname} - but it doesn't work, since "the class oracle.jbo.server.ViewRowImpl does not have the property dataProvider".
Sorry for the newbie question.
Thanks in advance for any help!Hi,
AFAIK, dataProvider is not supported on ADF BC, hence the error.
If you have created ADF Read only table and form from the same data control you just need to refresh the form based on table selection to show up the selected record, to do which you just need to add partialTriggers property to the panelFormLayout and set its value to the id of table
Sireesha -
Deleting BOTH duplicate rows in Excel
Hi everyone,
I have just been introduced to Applescript and I was hoping to automate some things at my workplace. One of the first activities that I have been trying to figure out involves Excel 2008, which is running on a G5 (Latest version of Mac OS X updated just today). It involves deleting both duplicates of records--file numbers--in a long one column list (there may soon be thousands of these records piling up, with many duplicates.)
Someone over at MacScripter ("mikerickson" @ http://macscripter.net/viewtopic.php?id=32340) posted the following code for using Excel autofilter to delete only one instance of each duplicate row:
*tell application "Microsoft Excel"*
*set myMessySheet to get worksheet "Sheet1" of workbook "Workbook2.xls"*
*set myMessyRange to get current region of range "A1" of myMessySheet*
*set myCleanRange to get resize (get offset (myMessyRange) column offset ((count of columns of myMessyRange) + 1)) row size 1*
*advanced filter myMessyRange action filter copy copy to range myCleanRange with unique*
*-- optional deletes dirty range*
*delete range (entire column of (get resize myMessyRange column size ((count of columns of myMessyRange) + 1))) shift shift to left*
*end tell*
This code works great when I copy and paste in Applescript Editor. Now, I need to find all duplicates in my data and delete both of the numbers, leaving only the single instance records/numbers. There are even instances where a number shows up three or more times; it would be great to get rid of those as well.
Thank you in advance to anyone who can help me with this.I think you're going to have a hard time doing this because the original script used Excel to do the heavy lifting (i.e. filter the duplicates). The keyword with unique in the advanced filter is what's doing that.
Off hand, I don't see an equivalent option for the filter that finds singletons in the list. Without that you'll need to iterate through the list manually, excluding the duplicate entries. -
SQL Server 2014 - Delete duplicate rows in a table except one
Hi all,
I have a table that contains duplicate rows. Using grouping I can easily identify those rows.
As of now, I count the grouped records and copy one of the group in a temporary table together with its count of elements. Than I loop over this table and delete N - 1 rows of each group from the original table. Unfortunately this is done with two cursors
and WHILE loops.
Is anybody out there who could give some hints how to handle deletion of duplicated rows leaving one in place using pure SQL? I tried a full delete of all elements of a group and then an INSERT of one row to recreate a row again. But this is not
very elegant and close to using cursors.
Regards UweHi all,
based on input below from Uri, I have developed a little more general solution for removal of duplicates. I did that, because I'm sure that for many beginners in SQL it is easier specialize a proposal by removing parts of it than adding new functionality.
Here is my code.
-- Remove duplicates from a table and document the deleted rows
DECLARE @MyTable Table (Col1 int, Col2 int, Col3 int, Col4 int);
DECLARE @OutTable Table (Col1 int, Col2 int, Col3 int, Col4 int);
INSERT INTO @MyTable VALUES
(1, 10, 100, 7),
(2, 20, 200, 2),
(2, 20, 200, 1),
(3, 30, 300, 3),
(1, 10, 200, 4),
(1, 10, 100, 5),
(1, 10, 100, 6);
WITH cte (RN, Col1, Col2, Col3, Col4)
AS (SELECT ROW_NUMBER() OVER (PARTITION BY Col1, Col2, Col3 ORDER BY (SELECT 0)) AS RN, Col1, Col2, Col3, Col4
FROM @MyTable)
DELETE FROM cte
OUTPUT DELETED.Col1, DELETED.Col2, DELETED.Col3, DELETED.Col4
INTO @OutTable (Col1, Col2, Col3, Col4)
WHERE RN > 1;
SELECT * FROM @OutTable;
And this is the result:
The MS 139444 article Satish mentioned is focussed on duplicate PKs removal. Thanks for the hint.
Thanks to you all for your rapid response.
Regards Uwe -
Displaying all the records in a tabular form on a single page
Hello,
After setting up a data entry page, I have hit an unexpected problem.
The logic in my page requires that all the records in my tabular form should be displayed .
The tabular form is based on a collection, and the user selects rows through a checkbox.
Any reload of the page due to pagination will break the logic, as some calculation and display events occur during page load,
based on the previous page.
I need to display about 25 rows.
I have changed the report attribute to display 50 rows, but it displays rows only up to the bottom of the screen,
i.e. 11 rows.
Unfortunately I only just added some new rows and saw this behaviour else I would not have gone that way,
as I expected APEX to display all rows if required.
Some help will be much appreciated.
Regards
Leckrajleckj wrote:
Hello,
After setting up a data entry page, I have hit an unexpected problem.
The logic in my page requires that all the records in my tabular form should be displayed .
The tabular form is based on a collection, and the user selects rows through a checkbox.
Any reload of the page due to pagination will break the logic, as some calculation and display events occur during page load,
based on the previous page.
I need to display about 25 rows.
I have changed the report attribute to display 50 rows, but it displays rows only up to the bottom of the screen,
i.e. 11 rows.
Unfortunately I only just added some new rows and saw this behaviour else I would not have gone that way,
as I expected APEX to display all rows if required.Pagination settings are cached for the duration of the session. For this change to be instantly visible, either log out, restart the brower, and log in again, or manually re-request the page from the browser address bar, adding 'RP' in the ClearCache position in the URL.
Maybe you are looking for
-
Help needed in inserting into column of XML type
i have requirement of inserting data into column of xml type eg cust product cost 1 a 3 1 b 7 1 c 5 now required result should <PROD-LIST> <a>3</a> <b>7</b> <c>5</c> </PROD-LIST> Please let me know how to achieve this , i was trying write function ,
-
I tried figuring out the icloud thing but all my settings are set to "on" so it should sync but it isn't... and plugging my ipod into my new computer doesn't change anything. The computer won't pick up the songs on the ipod and the ipod won't pick up
-
Cisco Auto Anchor Web Authentication - NAS IP Address
Hi, I've setup auto anchor web authentication for my guest network. I want my Web Authentication requests to be authenticated by ISE however need the authenticating device to be the Anchor Controller. I setup the WLAN to authenticate against ACS4.2 a
-
Hi, One of my friend has given this problem to me. I'm using 11g. Two tables t1, t2. No relation exist between these two tables. Please find the table Scripts below. -- Table t1 CREATE TABLE t1(col1 NUMBER, col2 NUMBER); INSERT INTO t1 VALUES (1,2);
-
How/where do I get iTunes for my 64-bit Windows.8 laptop computer?
I cannot connect with the iTunes software I have available; that is, I get an error saying the software i for 32-bit products but my laptop is 64-bit running Windows 8.1. Help!