Oracle Unique Row Identifer
I am an Oracle newbie type and need to do some basic synchronization between Oracle and another database. I need access to a unique row identifier to track changes to a row in a meta table. Does Oracle provide this sort of thing that is consistent between replicated Oracle database, or do I need to create my own sequence to do this?
Thanks.
You will need to use your own unique value to manage the synchronization.
Similar Messages
-
Name of built in unique row identifier field in Oracle
I believe that I read somewhere that each Oracle database table comes with a built in unique row identifier field. Could somebody please confirm whether this is true and if so, please tell me the name of that field.
Thanks.Are you referring to ROWID by any chance? If yes, this may help with the relevant information - http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i8776
Thanks
Chandra Pabba -
How to get a unique row in a value set
How to get a unique row in a value set which is used in concurrent program.
Example if a table contains 10 unique rows i need only one row to show.
Thanksadd conditions in where clause to supress the duplicate values.
On how to supress the duplicate values follow the link
http://oracleschools.com/index.php?topic=40.msg76#msg76
Thanks
Prudhvi
www.erpschools.com -
Query for how to display unique rows in a table
Can i have a query for displaying unique rows in a table.
use d query
select distinct col1,col2... from table ; -
Select unique rows from two tables...
Hi,
I have two tables, replies1 and replies2.
SQL> desc replies
Name Null? Type
URN VARCHAR2(36)
ADDRESS VARCHAR2(18)
FILESIZE NUMBER
AS_NUM VARCHAR2(6)
SQL> desc replies2
Name Null? Type
URN VARCHAR2(36)
ADDRESS VARCHAR2(18)
AS_NUM VARCHAR2(6)
Both of the tables have no primary keys, but I have indixes on (urn, addrss) combination on both....
I am trying to select the unique rows with (urn, address) from replies2, and then find the matching size from replies...
I am using the following query:
select distinct replies2.urn, replies2.address, replies.filesize from replies2, replies where replies2.AS_NUM like 'XYZ' and replies.urn = replies2.urn;
I cannot figure out why it won't work. the way I understand it is that, distinct will give all distinct combination of all column names that follow, which is what I want...
I know it is wrong, because the query:
select count(*) from replies2 where AS_NUM like 'XYZ' returns less number of rows than the above query.
Any help would be greatly appreciated.
Thank you
Oz.Thanks a lot Mohan for your reply.
urn is not a unique key. Several rows could have the same (urn, address) pair in both tables. What I want is retrieve all (urn, address) rows from one table, and find the size from the other table to make a (urn, address, size). I want all unique combinations of (urn, address) to appear in the output.
AS_NUM is an empty column in replies... It would've been a lot easier if it wasn't, since then I'll just say: select distinct urn, address, filesize from replies where AS_NUM like 'XYZ';
I will try your query though and let u know how it goes. It takes quite a while to run since my tables are huge. -
SQL query - return single unique rows
Hi
If you have an employee table where employees are listed per department, using SQL, how could you return the names of the employees listed per department on a single unique row?
Eg - select deptno, first_name from employee
deptno first_name
10 Jane
20 Jack
10 Joe
20 Jill
10 Jacinta
30 John
30 Jeffrey
10 Jackie
30 Jennifer
... etc.
the return set of the query would look like:
deptno first_name concat
10 Jane Joe Jacinta Jackie ..
20 Jack Jill ..
30 John Jeffrey Jennifer ..
CheersHere you go:
WITH t AS
(SELECT 10 deptno, 'Jane' first_name FROM dual UNION
SELECT 20 deptno, 'Jack' first_name FROM dual UNION
SELECT 10 deptno, 'Joe' first_name FROM dual UNION
SELECT 20 deptno, 'Jill' first_name FROM dual UNION
SELECT 10 deptno, 'Jacinta' first_name FROM dual UNION
SELECT 30 deptno, 'John' first_name FROM dual UNION
SELECT 30 deptno, 'Jeffrey' first_name FROM dual UNION
SELECT 10 deptno, 'Jackie' first_name FROM dual UNION
SELECT 30 deptno, 'Jennifer' first_name FROM dual)
SELECT deptno,
RTRIM(XMLAGG(XMLELEMENT(c, first_name||' ') ).EXTRACT ('//text()'), ' ') names
FROM t
GROUP BY deptno -
Unique row based on two columns and single column
Dear Members,
I have a table which contains duplicate rows, for which a query should be able to fetch the unique row from the table. Here the unique is not based on one column, but it should be on two columns and also check for uniqueness on one column.
create table addr ( firstname varchar2(10), lastname varchar2(10), area varchar2(3));
insert into addr values('bob', 'james', '1');
insert into addr values('bob', 'james', '1');
insert into addr values('harry', 'bert', '1');
insert into addr values('jimmy', 'bert', '1');
insert into addr values('sam', 'mac', '1');
insert into addr values('sam', 'knight', '1');
insert into addr values('tom', 'sand', '1');
insert into addr values('cat', 'mud', '1');
The output of query should contain 3 rows.
bob - james
harry - bert or jimmy - bert [ either one of them, but not both ]
sam - mac or sam - knight [ either one of them, but not both ]
tom - sand
cat - mud
SELECT firstname, lastname as total from addr WHERE area = '1' GROUP by firstname,lastname; This does not take of single column duplication..
Any suggestions..SQL> with t_data
as
select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
select 'bob', 'james', '1' from dual union all
select 'harry', 'bert', '1' from dual union all
select 'jimmy', 'bert', '1' from dual union all
select 'sam', 'mac', '1' from dual union all
select 'sam', 'knight', '1' from dual union all
select 'tom', 'sand', '1' from dual union all
select 'cat', 'mud', '1' from dual
SELECT
firstname,
lastname,
area
FROM
SELECT
t.*,
row_number() over(partition BY firstname order by 1) rn,
row_number() over(partition BY lastname order by 1) rn1
FROM
t_data t
WHERE
rn = 1
AND rn1 =1 ;
FIRSTNAME LASTNAME AREA
bob james 1
cat mud 1
jimmy bert 1
sam knight 1
tom sand 1
SQL> -
Selecting unique rows in ADF ViewObject
Hi,
In my ADF application, i am fetching data from a table. the situation is, my table is having same row of data multiple times. The primary key is a sequence. I want to fetch distinct rows of data from the table.
So, I wrote query to fetch the distinct rows of the table.
The query works in the Database SQL worksheet, but when i use it in my ViewObject and run, it throws an error saying
View object ActiveUsersVO does not include a primary key attribute Pk of entity base ExtUserMapping.here Pk is my primary key. I did not used it in the query to get the unique rows.
help me fetch the unique rows in ADF without the primary key
thanks,
RajanUser please tell us yor jdev version!
This should be no problem as long as your VO is build as road only based on a query like
select distinct department_id from job_historyThis VO can be used without a PK, however some function which are working on PKs won't work. The query works on hte HR schema.
Timo -
Interactive report unique row count
Hi,
I just want to know if there is a way to do a row count with a unique on an interactive report column.
What I mean is that I have a report that looks like that
Project Project type Hours
Project 1 Project type 1 1
Project 2 Project type 2 1
Project 1 Project type 1 1
Project 3 Project type 3 1
Project 2 Project type 2 1
I would like to do a unique on the project name. So, at the end, I would like to have a count that says that I have 3 different projects.
Is there anyway to do that ?
Thanks,
ChantaleHi Chantale - did you manage to solve this one?
Example here (http://apex.oracle.com/pls/otn/f?p=11189:1) showing 14 rows, but only 7 distinct rows. These duplicates are valid, and the SQL cannot be changed. Is there a way through the IR to show a count of 7 (the distinct rows)?
Thanks,
Mike
Edited by: Mike, UK on Oct 2, 2009 12:04 PM -
Unique row count in table footer
JDev 11.1.1.6
Hi,
In my current table, I am able to show total row count at a table footer by using #{bindings.<myVO>Iterator.estimatedRowCount}.
I have a request from my user to show unique total row count. For example rows below:
1 A
2 B
3 A
4 C
The footer should show:
4 3
The second column has A, B, and C where A is counted only 1 (unique). Is there a way to achieve this?
Thanks.Hi RRA,
This may work for a static # of rows (no filtering). In the table I use, I can do filtering and that certainly will make the count result be different if I use another VO for distinct result.
Thanks. -
My final data table contains a two key columns unique key constraint. I insert data into this table from a daily capture table (which also contains the two columns that make up the key in the final data table but are not constrained
(not unique) in the daily capture table). I don't want to insert rows from daily capture which already exists in final data table (based on the two key columns). Currently, what I do is to select * into a #temp table from the join
of daily capture and final data tables on these two key columns. Then I delete the rows in the daily capture table which match the #temp table. Then I insert the remaining rows from daily capture into the final data table.
Would it be possible to simplify this process by using an Instead Of trigger in the final table and just insert directly from the daily capture table? How would this look?
What is the best practice for inserting unique (new) rows and ignoring duplicate rows (rows that already exist in both the daily capture and final data tables) in my particular operation?
Rich PPlease follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> My final data table contains a two key columns unique key constraint. [unh? one two-column key or two one column keys? Sure wish you posted DDL] I insert data into this table from a daily capture table (which also contains the two columns that make
up the key in the final data table but are not constrained (not unique) in the daily capture table). <<
Then the "capture table" is not a table at all! Remember the fist day of your RDBMS class? A table has to have a key. You need to fix this error. What ETL tool do you use?
>> I don't want to insert rows from daily capture which already exists in final data table (based on the two key columns). <<
MERGE statement; Google it. And do not use temp tables.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How to show a unique Row-ID even if the rows become re-sort
I would like to have unique-ids for each row to identify the row even though the order of the rows change.
before you sort you could add a new column and place an incrementing number in each row. To do this...
1) create a new column (right click in the column header, one of the letters are the top) and select "Add Column..." choose whether Before ar After
Make the first row a header and title the new column something like "Original Sort Order". Then in the first row of the new column type a "1", and in the second row type "2". Now select the first and second cells of the new column.
hover the cursor over the hollow circle at the bottom-right corner of the selection. The cursor will change to a "+". Now click, and hold, on the you can fill the pattern down the column as needed. Now you can always sort by this column to get your original order back. -
I am really stupid of this right now. Have not tried the regular SQL for long time, so my question is that I have a table- Cost
A B C D E F
0002 6002 5 55 68.35 6.12
0003 6003 5 99.26 89.33 8.23
0004 6004 5 78.85 4.4 7.42
0004 6004 6 78.85 8.1 1.7
0004 6004 7 78.85 70.9 6.73
0005 6005 5 49.88 76.1 68.53
0005 6005 6 49.88 93.7 18.57
0005 6005 7 49.88 255.7 63
How can I get the column E and F, when I want to get the row with highest order in C as result in
A B C D E F
0002 6002 5 55 68.35 6.12
0003 6003 5 99.26 89.33 8.23
0004 6004 7 78.85 70.9 6.73
0005 6005 7 49.88 255.7 63
I used the max () and group by in query as
select A, B, max(C), D
from cost
group by A,B,D
If I added the max(E) and max(F) in the SELECT, I got correct row in E but not the F.
Please help me out. Thanks.an alternative using analytic fiunctions would be:
select "A","B",max("C"),"D","E","F" from
(select "A","B","C",last_value("D") over (partition by "A","B" order by
"A","B","C" rows between unbounded preceding and unbounded following) "D",
last_value("E") over (partition by "A","B" order by
"A","B","C" rows between unbounded preceding and unbounded following) "E",
last_value("F") over (partition by "A","B" order by
"A","B","C" rows between unbounded preceding and unbounded following) "F"
from test1)
group by "A","B","D","E","F"
order by "A","B"
this appears to give a better plan on the test data but you would want to test with a larger volume, we have reduced to numbet of buffer gets but added two sorts currently these fit in memory but you may find with a larger dataset these result in disk sorts.
Chris
Autotrace output:
SQL> select * from test1 where "A"||B||"C" in (select "A"||B||Z from (select "A", B, max("C") Z from test1 group by "A",B));
A B C D E F
0002 6002 5 55 68.35 6.12
0003 6003 5 99.26 89.33 8.23
0004 6004 7 78.85 70.9 6.73
0005 6005 7 49.88 255.7 63
Execution Plan
Plan hash value: 2706139598
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 50 | 8 (25)| 00:00:01 |
|* 1 | HASH JOIN | | 1 | 50 | 8 (25)| 00:00:01 |
| 2 | TABLE ACCESS FULL | TEST1 | 8 | 192 | 3 (0)| 00:00:01 |
| 3 | VIEW | VW_NSO_1 | 8 | 208 | 4 (25)| 00:00:01 |
| 4 | HASH UNIQUE | | 8 | 104 | 4 (25)| 00:00:01 |
| 5 | HASH GROUP BY | | 8 | 104 | 4 (25)| 00:00:01 |
| 6 | TABLE ACCESS FULL| TEST1 | 8 | 104 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("$nso_col_1"="A"||"B"||TO_CHAR("C"))
Statistics
0 recursive calls
0 db block gets
64 consistent gets
0 physical reads
0 redo size
795 bytes sent via SQL*Net to client
381 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
4 rows processed
SQL>
SQL> select "A","B",max("C"),"D","E","F" from
2 (select "A","B","C",last_value("D") over (partition by "A","B" order by
3 "A","B","C" rows between unbounded preceding and unbounded following) "D",
4 last_value("E") over (partition by "A","B" order by
5 "A","B","C" rows between unbounded preceding and unbounded following) "E",
6 last_value("F") over (partition by "A","B" order by
7 "A","B","C" rows between unbounded preceding and unbounded following) "F"
8 from test1)
9 group by "A","B","D","E","F"
10 order by "A","B";
A B MAX("C") D E F
0002 6002 5 55 68.35 6.12
0003 6003 5 99.26 89.33 8.23
0004 6004 7 78.85 70.9 6.73
0005 6005 7 49.88 255.7 63
Execution Plan
Plan hash value: 3359524756
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 8 | 496 | 5 (40)| 00:00:01 |
| 1 | SORT GROUP BY | | 8 | 496 | 5 (40)| 00:00:01 |
| 2 | VIEW | | 8 | 496 | 4 (25)| 00:00:01 |
| 3 | WINDOW SORT | | 8 | 192 | 4 (25)| 00:00:01 |
| 4 | TABLE ACCESS FULL| TEST1 | 8 | 192 | 3 (0)| 00:00:01 |
Statistics
0 recursive calls
0 db block gets
7 consistent gets
0 physical reads
0 redo size
802 bytes sent via SQL*Net to client
381 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
4 rows processed
SQL> -
Button click row identification in af:table
i have an af:table whose 1 column contains buttons. Clicking on each button i want to do some step. How do i determine which button was clicked (which row) ?
its an adf faces project.
thnksThe suggestion provided by Timo Should work.
Here, is an sample based on Employees Table based on HR Schema.
Ensure that the selection listener for the table is selected as single.
JSPX Page:
<af:form id="f1">
<af:table value="#{bindings.Employees.collectionModel}" var="row"
rows="#{bindings.Employees.rangeSize}"
emptyText="#{bindings.Employees.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings.Employees.rangeSize}"
rowBandingInterval="0"
*selectedRowKeys="#{bindings.Employees.collectionModel.selectedRow}"*
*selectionListener="#{bindings.Employees.collectionModel.makeCurrent}"*
*rowSelection="single"*
id="t1">
<af:column sortProperty="EmployeeId" sortable="true"
headerText="#{bindings.Employees.hints.EmployeeId.label}"
id="c4">
<af:outputText value="#{row.EmployeeId}" id="ot2">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.Employees.hints.EmployeeId.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="FirstName" sortable="true"
headerText="#{bindings.Employees.hints.FirstName.label}"
id="c1">
<af:outputText value="#{row.FirstName}" id="ot3"/>
</af:column>
<af:column sortProperty="LastName" sortable="true"
headerText="#{bindings.Employees.hints.LastName.label}"
id="c3">
<af:outputText value="#{row.LastName}" id="ot4"/>
</af:column>
*<af:column headerText="#{'View Details'}" id="c2">*
*<af:commandButton text="View Details" id="cb1"*
*actionListener="#{SamplePageBean.onClick}"/>*
*</af:column>*
</af:table>
</af:form>
*Bean Code:*
import javax.faces.event.ActionEvent;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
public class SamplePageBean {
public SamplePageBean() {
public void onClick(ActionEvent actionEvent) {
DCBindingContainer dcBindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
// Get a attribute value of the current row of iterator
DCIteratorBinding iterBind =
(DCIteratorBinding)dcBindings.get("EmployeesIterator");
String firstName =
(String)iterBind.getCurrentRow().getAttribute("FirstName");
String lastName =
(String)iterBind.getCurrentRow().getAttribute("LastName");
System.out.println(firstName + " " + lastName);
Thanks,
Navaneeth -
Hi,
SELECT main_grp_name,category,sub_category,commodity_name
FROM category_list
WHERE main_grp_name IN(
SELECT main_grp_name
FROM category_list
GROUP BY main_grp_name
HAVING COUNT (distinct category)<=3 )
This is a query which should give me unique main_grp_name and category..
For a main_grp_name there can be three category name or less but it should be unique... But now I hve a case where there are two rows with same main_grp_name and same category_name.. In this case I should look for sub_category and based on that I should pick up only one row
eg: the query returns the following
MAIN_GRP_NAME CATEGORY SUB_CATEGORY COMMODITY_NAME
MEDICINE whole_sale Trauma ABC
MEDICINE whole_sale Anxiety SYX
MEDICINE retail Trauma SSS
MEDICINE mail Anti_psy GGG
Here I should get only one out of first two rows as I am considering only MAIN_GRP_NAME and CATEGORY as the criteria.
If I have two rows with same value for these fields then I should look for SUB_CATEGORY and select the row with VALUE 'ANXIETY'
eventually I should have only
MEDICINE whole_sale Anxiety SYX
MEDICINE retail Trauma SSS
MEDICINE mail Anti_psy GGG
Anybody please help
regardsSQL> WITH t AS
2 (SELECT 'MEDICINE' main_grp_name, 'whole_sale' CATEGORY,
3 'Trauma' sub_category, 'ABC' commodity_name
4 FROM DUAL
5 UNION ALL
6 SELECT 'MEDICINE', 'whole_sale', 'Anxiety', 'SYX'
7 FROM DUAL
8 UNION ALL
9 SELECT 'MEDICINE', 'retail', 'Trauma', 'SSS'
10 FROM DUAL
11 UNION ALL
12 SELECT 'MEDICINE', 'mail', 'Anti_psy', 'GGG'
13 FROM DUAL)
14 SELECT main_grp_name, CATEGORY, sub_category, commodity_name
15 FROM (SELECT t.*,
16 ROW_NUMBER () OVER (PARTITION BY main_grp_name, CATEGORY ORDER BY sub_category)
17 rn
18 FROM t)
19 WHERE rn = 1;
MAIN_GRP CATEGORY SUB_CATE COM
MEDICINE mail Anti_psy GGG
MEDICINE retail Trauma SSS
MEDICINE whole_sale Anxiety SYX
SQL> Edited by: Salim Chelabi on 2009-02-12 09:57
Maybe you are looking for
-
Books and pdf on IPad don't appear in IBooks on MAC
I've read through several solutions to this similar problem and none of the solutions work for me. I've uploaded several ebooks to my mac and they don't appear on the IPad. I've got content (PDF's) on my ipad that doesn't appear on my mac. For exampl
-
How to receive a xml CDATA in string element when OSB calling a webservice?
How to receive a xml CDATA in string element when OSB calling a webservice? I have a business service (biz) that route to operation of a webservice. A example of response to this webservice legacy: <soapenv:Envelope xmlns:soapenv="http://schemas.xmls
-
How do I get my trash under all inboxes?
How do I move my trash from under icloud mailbox to all mailboxes?
-
Hi, I am running InDesign CS3 5.0.4 and am suddenly unable to place an image in a document, either using the menu or the shortcut, and file, new or existing. CS3 crashes instantly (and asks me what I was doing when it crashed). This makes the program
-
This is the version that i have. When i try to update the software from iTunes, it says the software is up to date. Does it mean that I cannot upgrade to higher versions of iOS ?