duplicates of records in the table
HelloI have the following type and I need to delete duplicate records
declare
type x_object_type is table of number
index by binary_integer;
x_table x_object_type;
idx number;
begin
select manager_id bulk collect into x_table
from employees
where rownum <= 6;
idx := x_table.first;
for i in x_table.first..x_table.last loop
if idx = x_table.next(i) then
dbms_output.put_line('it is a duplicate');
else
dbms_output.put_line('no duplicate '||x_table(i));
end if;
idx := x_table.next(i);
end loop;
end;
the result is:
no duplicate 207
no duplicate 124
no duplicate 101
no duplicate 100
no duplicate 201
no duplicate 101
as you can see I have duplicated lines. This is an example, the values in the table are not stored in a table to eliminate using rowid.Thank you
Hi coco problem already solved?
In my view, that there are some problems in comparison. Try this:
declare
type x_object_type is table of number
index by binary_integer;
x_table x_object_type;
idx number;
dup boolean;
begin
select manager_id bulk collect into x_table
from hr.employees
where rownum <= 6;
--idx := x_table.first;
for i in x_table.first..x_table.last-1 loop
idx := x_table(i);
--dbms_output.put_line('Now checking '||idx||' for duplicates.');
dup := false;
for a in x_table.first..x_table.last loop
if idx = x_table(a) and a != i then
dup := true;
end if;
end loop;
IF dup then
dbms_output.put_line('it is a duplicate: '||x_table(i));
else
dbms_output.put_line('no duplicate: '||x_table(i));
END IF;
end loop;
end;
/
You choose the first value and then wrap well than all the others. If you need 2 loops and this "idx: = x_table.first;" the nr of the table not returns.
But, as a suggestion, use a table function. It's more fun:
CREATE TYPE numset_t IS TABLE OF NUMBER;
CREATE OR REPLACE FUNCTION GET_manager_id RETURN numset_t PIPELINED
IS
BEGIN
FOR i in (select manager_id
from employees
where rownum <= 6 AND manager_id IS NOT NULL) LOOP
PIPE ROW(i.manager_id );
END LOOP;
RETURN;
END;
/
select a.column_value,count(*) from
(SELECT DISTINCT column_value FROM table(GET_manager_id())) a
INNER JOIN table(GET_manager_id()) b
ON a.column_value = b.column_value
group by a.column_value
order by a.column_value;
If the code is much easier and you have total flexibility, SQL.
-andy
Tags: Database
Similar Questions
-
How can I recover only odd or even number of records in the table?
Hello
How can I recover only odd or even number of records in the table?
Thank you
Hi IndiMinds,
Alternatively, you can use in queries. :
Odd:
SELECT *.
Of
(SELECT rownum row_count, id, name FROM bigemp
)
WHERE mod (row_count, 2) = 1;
Still:
SELECT *.
Of
(SELECT rownum row_count, id, name FROM bigemp
)
WHERE mod (row_count, 2) = 0;
Thank you
-
Not able to read the values in group by, when no records in the table
Hi all, I have this query
Select p.header_id,
Type "some_constant."
sum (nvl (p.total_amount, 0)) sum_of
from table_name p
P.header_id group
When there is record in the table, it works fine, but I want to if there is no any folder that it returns as below,
header_id type sum_of
some_constant 0 0
How to...?
Help, please.
Kind regards
SELECT * FROM (select p.header_id,
Type "some_constant."
sum (nvl (p.total_amount, 0)) sum_of
from table_name p
P.header_id group
UNION ALL
SELECT 0,
BOX WHEN (SELECT COUNT (*) FROM table_name) = 0 THEN type of 'some_constant',
ANOTHER NULL
END type as,
0
THE DOUBLE)
WHERE type IS NOT NULL;
Post edited by: 000000
-
Total number of records in the table read
Here is the procedure to read total no of record in the table specified by the user during execution. But it still gives the same answer for all the table. Can someone help me?
create or replace procedure p3 (varchar2, not on the number tab)
as
Start
Select count (*) from no tab;
end;You need dynamic SQL statements.
Or:
http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html
To get the name of the Table and no lines
http://asktom.Oracle.com/pls/asktom/f?p=100:11:1725645184471282:P11_QUESTION_ID:1660875645686Or simply use the data dictionary, collect statistics of the table, then:
Select table_name, num_rows from user_tables; -
How to find inserted last record in the table.
Version: Oracle 10g
I have a table called 'Manufacturing' and 3 columns as mfno, itemname, quantity.
How to find inserted last record in the table 'manufacturing '.
As I got to know that the Rowid is not a result perfect result. Please provide your inputs.user13416294 wrote:
Version: Oracle 10gThis is not a version. It's a product name. A version is 10.1.0.2 or 10.2.0.4, etc.
I have a table called 'Manufacturing' and 3 columns as mfno, itemname, quantity.
How to find inserted last record in the table 'manufacturing '.Not possible as your data model do not answer for him. As simple as that.
If there is a need to determine an order or associate some time to an entity, then that should be part of the data model - and a relationship, or one or several attributes are necessary to represent this information. Your data model in this case is therefore unable to meet your requirements.
If the requirements are valid, set the data model. In other words - your question has nothing to do with Oracle and nothing to do with the other pseudo columns in Oracle, the rowscn or the rowid. It is a question of pure data modeling. Nothing more.
-
Create record in the Table of results gives error
Hi all
Update page there is a table of results with the Add button to create a new line.
Everything by creating a new record on the table of results gives an error
The attributes defined for AccessId in the view object xxlcupdvariablesvo1 failed
I checked the EO and VO attributes, everything seems to be good.
Updatable also has the value "Always".
Still don't know why this error is coming.
Please help resolve this error.
Thank you
SKSK
Don't forget that your AO made correctly and you do your from VO of the two OS after this AO. If possible, allow Jdev to create your AO. Try to create is not in manuallly
Hope it solves your problem
Thank you
AJ -
Add new records to the table of the ADF
Hello
I use Jdev 11.1.1.3.0.
I have a Page of the ADF with detail Table of form - master, I want to add new records to the table reflecting in DB. Is it possible to do? pointers or demo?
Thank you
MBWhat are the components are used in your table? When you created the table originally, you specified as a table read-only? If your table contains components of af: outputText, then you will need either manually change components entry way, or remove the table and re-drop-the-in the form of table (not read-only)
John
-
Form check synchronize on Popup to the selected record from the table
I'm trying to recreate what I did on the portals of the OAS in Weblogic/ADF. I have JDeveloper 11.1.1.2.0. What I do seems to be a little different than the tutorials: I need something like the tutorial master-detail, but instead the details appearing on the same page, it should appear in a popup. I managed to build the part table/popup. But when the popup appears, it displays the wrong record. Here are the steps I used to create this page:
After you create the ADF Fusion Middleware project:
1 create templates for the tables I need.
2. create the JSF Page.
3 drop panelCollection on the page.
4. remove my data to see in panelCollection control and choose the Table read-only ADF. Select the sorting and selection options.
5 change table properties: selected = DisplayRow, EditingMode = clickToEdit
6 drag the Popup on the page.
7. remove my data from view in popup control and choose the form of the ADF. Select the send option.
8 drop showPopupBehavior on the page. Name of the popup. The value triggerType to the 'selection '. (triggerType "click" works, too)
9 deploy.
The table is displayed. I click on a line. The pop-up window appears. The form of popup displays the first record in the table. I click on any line.
I just bought the merger Oracle 11g Developer Guide, but were not able to answer this question yet.
Any ideas?
Thank you.See this video for how it works for me:
http://www.ScreenToaster.com/watch/stWUtcRkVLQ1BcSV1aX15Q -
Purge of the records of the Table and the size of the data file
11.2.0.4/Oracle Linux 6.4
We want to reduce the size of the DB (file size of data), so that our RMAN backup size will be reduced. So, let's create stored procedures that will purge old data in huge tables.
After you remove records, we will decrease the tables using the:
change the movement line of table ITEM_MASTER enable;
change the waterfall table retractable ITEM_MASTER space;
ALTER table ITEM_MASTER deallocate unused;
The commands above will reduce the file size of data (see dba_Data_files.bytes) or it will reduce the size of the segment?
Only the segment formats will be reduced. Oracle has never reduced the sizes of data file automatically. You would have to reduce them. You may not be able to reduce the size of data file if there are extensions to the 'end' (highwatermark) data files. In this case, you will need to create a new tablespace and move all the objects for the new tablespace OR export, drop, create tablespace and import.
Hemant K Collette
-
Update the records in the table
I have an INCOME_LOT table. Now, I need to update records with the current max (lot_id) + rownum where lot_id = 0.
Note: There are multiple records with lot_id = 0.CREATE TABLE INCOME_LOT
(
LOT_ID NUMBER OF NON-NULL,
NUMBER OF DETAIL_ID
DATE OF EFFECTIVE_DATE,
DATE OF UPDATE_DATE
)
It is only a sample data of 4 records, while in fact, I have millions of records to be updated.Insert into INCOME_LOT
(LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
Values
(0, 5773490, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into INCOME_LOT
(LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
Values
(0, 5773491, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into INCOME_LOT
(LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
Values
(0, 5773492, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into INCOME_LOT
(LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
Values
(0, 5773493, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:41 ',' DD/MM/YYYY HH24:MI:SS'));))
COMMIT;Can someone help me to update all records with a single SQL query or maybe a PL/SQL block? I could design a cursor to update, but it would be tedious to use.
Do you want this:
UPDATE INCOME_LOT
Set lot_id = 262696 + ROWNUM
WHERE lot_id = 0;
-
Add the record to the table of lots
I am importing data which is about 200 files without header or footer. Is there a way to trigger an AUTOTEXT entry IN the batch TABLE (Id = sequence, Date = sysdate, dealing = 'test' as well?)
You can create a separate control file and make it a race separate from SQL * Loader, as demonstrated below, immediately before loading your data.
Scott@orcl12c > type host test.ctl
load data
INFILE *.
Add
set of table
fields
(ld "ld_seq.nextval"
, ld_date 'sysdate.
the constant process 'test')
begindata:
whatever
Scott@orcl12c > create table batch
2 (number of ld,
date of ld_date 3.
4 process varchar2 (7))
5.
Table created.
Scott@orcl12c > create sequence ld_seq
2.
Order of creation.
Scott@orcl12c > host sqlldr scott/tiger control = test.ctl log = test.log
SQL * Loader: release 12.1.0.1.0 - Production on Thu Apr 10 23:48:29 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Path used: classics
Commit the point reached - the number of logical records 1
Table batch:
1 row loaded successfully.
Check the log file:
test.log
For more information on the charge.
Scott@orcl12c > select * batch
2.
LD LD_DATE PROCESS
---------- --------------- -------
Thursday, April 10, 2014 1 test
1 selected line.
Scott@orcl12c > host sqlldr scott/tiger control = test.ctl log = test.log
SQL * Loader: release 12.1.0.1.0 - Production on Thu Apr 10 23:48:29 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Path used: classics
Commit the point reached - the number of logical records 1
Table batch:
1 row loaded successfully.
Check the log file:
test.log
For more information on the charge.
Scott@orcl12c > select * batch
2.
LD LD_DATE PROCESS
---------- --------------- -------
Thursday, April 10, 2014 1 test
2 tests Thursday, April 10, 2014
2 selected lines.
-
by comparing the number of records in the table child
I have 3 tables below:
Table 1 - Parent Table
Table table2 child - who has the number of records for each record in Table1 (row_id in Table1 corresponds to par_row_id in Table2)
Child table table 3 - has that number of records for each record in Table1 (row_id in Table1 corresponds to par_row_id in table 3)
I would like to run an Oracle SQL query to identify all the separate row_id on Table1, for which the number of child records in Table2 does not match the number of child records in Table3
I ask for help to identify the best way to identify these records in the parent table. If possible an example too, please.
Thank you
Published by: cseshan on February 3, 2013 01:35All by adding the simplest example (with the sample data that you were supposed to provide) below
create table table1(row_id number primary key); create table table2(par_row_id number references table1); create table table3(par_row_id number references table1); insert into table1 values(1); insert into table2 values(1); insert into table3 values(1); insert into table1 values(2); insert into table2 values(2); insert into table2 values(2); insert into table1 values(3); insert into table3 values(3); insert into table3 values(3); insert into table1 values(4); insert into table2 values(4); insert into table2 values(4); insert into table2 values(4); insert into table3 values(4); insert into table3 values(4); commit; with child1_cnt as ( select par_row_id,count(*) cnt from table2 group by par_row_id ), child2_cnt as ( select par_row_id,count(*) cnt from table3 group by par_row_id ), all_counts as ( select p.row_id,nvl(c1.cnt,0) c1_cnt,nvl(c2.cnt,0) c2_cnt from table1 p left outer join child1_cnt c1 on ( p.row_id = c1.par_row_id ) left outer join child2_cnt c2 on ( p.row_id = c2.par_row_id ) ) select row_id,c1_cnt,c2_cnt from all_counts where c1_cnt != c2_cnt; ROW_ID C1_CNT C2_CNT ------ ------ ------ 2 2 0 4 3 2 3 0 2
-
Get the value of the record in the table and set the Disabled property...
Hello! I have the table in my JSPX page. I search for records and that you press one of the files with a right click, see: http://my.jetscreenshot.com/2677/20120203-fas1-30kb
I put property disabled like that of my commandMenuItem:
But as you can see in my photo above, the disabled property do not work. Where I am wrong with my code:#{row.GenResGrupa != 'true'}
Please correct me! If you need further information, please let me know.<af:commandMenuItem text="#{sampleBundle.pases}" id="commandMenuItem1" action="adfMenu_pasesDati" actionListener="#{bindings.setCurrentRowWithKeyValue.execute}" disabled="#{row.GenResGrupa != 'true'}"/>
Best regards, Debuger!Dear Debuger,
Add in your pageDef:
And in your jspx:
Disabled = ' #{bindings. " GenResGrupa.inputValue! = 'true'} '.NOTE: no disabled = "#{row.bindings.GenResGrupa.inputValue! = 'true'} '"
-
exp/imp only a few records in the table
Hello
Exp/imp few records in my table during the activity level exp/imp table is possible?
If so, what setting should I be using
For example,.
I have 10000 records in my narration of the table "TEST_TB".
I have the dump full exp for the table.
But I want to just imp only 50000 records from the same table in another schema.
How would it be possible?
Please suggest me on this
Kind regards
FaizHello
It seems not possible to limit the number of rows that is imported, but it is possible to limit the number of rows exported with the query parameter, found examples
http://www.orafaq.com/wiki/Import_Export_FAQ
http://docs.Oracle.com/CD/B28359_01/server.111/b28319/exp_imp.htm#autoId52HtH
Johan -
How can I build a list of value form a single record in the table
I have the recording of the following table
: User_Id: Defaule_Role: Role_1: Role_2: _3 role:
________________________________________________
: 25: 1: 2: 3: 5:
How can I display this record as a list of valueIf you use an Oracle 11 g server behind the scenes, consider using the SQL UNPIVOT command. Check out the blog of Tim Hall on the UNPIVOT operator control:
http://www.Oracle-base.com/articles/11g/PivotAndUnpivotOperators_11gR1.php
Note that you need to use a read-only view in British Colombia ADF object to achieve this.
DMI
Maybe you are looking for
-
Since the update 8.0.1 a few days ago, I get this message from server that I can't access my Hotmail account I've been using FIREFOX for YEARS, but if I can't access my Hotmail account, BYE
-
HP Envy M6: Stop BIOs Code
I'm trying to get into my BIOs and do not remember the password since its been about 2 years since I have read the manual and I get the stop code 95402496.
-
Dividing into sub-groups Contacts
How can I share my contacts into sub-groups, i.e. the Quilters and golfers
-
MacShiny the experience of someone?
So, my wife gave me his MacBook when it was updated, I'm only a few months as a Mac convert and feeling my way. One of the first things I noticed was the slow my computer seemed to work, I ran the ClamXV she had asked any questions, didn't seem to ha
-
How to transfer programs to the newly added existing SSD HARD drive
I use a PC with Windows XP 3 SP 3 on a 250 MB HARD drive. Recently, I upgraded my processor and motherboard to a 3.00 gigahertz Intel Pentium Dual-Core64 kilobyte primary memory cache/2048 KB secondary memory cache/64-bit ready/Multi-core (2 total) /