SQL & PL/SQL :: Creating Sequence On Duplicate Data Through Query

Nov 18, 2011

I have a table with three columns mentioned below :

Col1 Col2 Col3
121
221
331
431
531
622
722

Col1 is the primary key.I need a sql query which will show the data set mentioned below :

Col1 Col2 Col3 Seq
121 1
221 1
331 2
431 2
531 2
622 3
722 3

I need all the 7 records to be displayed.

View 16 Replies


ADVERTISEMENT

Client Tools :: Creating Sequence Value After Data Import?

Feb 23, 2011

I have an excel sheet as follows: I have to import the data in the excel sheet to oracle database table through TOAD.

name1 name2 name3
ABS SDFG FHTR
DFR GHJK HJK
... ... ...

Now, I need an id column along with these three that would have id numbers like that of a sequence. That means, suppose I have 1000 records in the excel sheet, then the table should have as many numbers automatically after data import.

View 18 Replies View Related

Duplicate Sequence Number For Identical Rows

Jul 5, 2010

I have a table:

Name
_____
Smith Street
Smith Street
John Street
Ed Street
Ed Street
Ed Street

and need to assign sequence numbers only when the record (Name) changes, e.g. :

Name Seq
_____ ____
Smith Street 1
Smith Street 1
John Street 2
Ed Street 3
Ed Street 3
Ed Street 3

I have experimented with row_number partition but then i just get the sequence returning to 1 when the name value changes.

If I grouped the records by Name I would like to have unique, sequential numbers: 1, 2, 3 but where there is the same name I would like the sequence to stop and the number to replicate?

View 9 Replies View Related

PL/SQL :: Update Duplicate Records In Table With Sequence Value

Mar 25, 2013

My table have duplicate records. I want to impose a primary key on that table. For that I have to replace duplicate values of a column with next value of a sequence.

View 2 Replies View Related

SQL & PL/SQL :: Creating Sequence - Select Returns Integer

Oct 18, 2010

im creating sequences for an already created db and need to set MINVALUE to sequences.

create sequence tb_1
minvalue X
start with X;

so, X == select Max(id_tb1) from tb_1.

I need that select returns an integer.

How can I do this??

View 11 Replies View Related

SQL & PL/SQL :: Creating Loop - Sequence Should Add A Number In The End Of Variables

Jun 12, 2013

SELECT
DECODE(BREINV1.NAMEKEY, NULL,'0','1') "BRE_INV1",
DECODE(BREINV1.NAMEKEY, NULL,' ',BREINV1.SEQUENCE) "BRE_NUMINV1",
DECODE(BREINV1.NAMEKEY, NULL, ' ', DECODE(BREINV1.SEQUENCE,NULL,NULL,

[Code]....

My problem, I have the query which works correctly. However as you can see there is always a sequence number in the end of variables and I am not sure the total number of cases, so I have to create a loop for the same query.

I am doing the same things on BREINV1 BREINV2 BREINV3 BREINV4... AND BRENUMINV1 BRENUMINV2... so the sequence should add a number in the end of variables...

View 39 Replies View Related

PL/SQL :: Error When Creating A Table / ORA-00957 - Duplicate Column Name

Mar 23, 2013

I'm getting an error as follows .

create table asgnd_agent_bak as (Select * from ASGND_AGENT a, SCN s
where
a.CNTCT_KEY = s.CNTCT_KEY and a.SCN_NUM=s.SCN_NUM
and a.ACTVTY_DT = to_date('03/17/2013','mm/dd/yyyy')
and s.SCN_OPEN_DT = to_date('03/15/2013','mm/dd/yyyy')
and a.SRC_SYS_DESC = 'FACET');
create table asgnd_agent_bak as (Select * from ASGND_AGENT a, SCN s
*
ERROR at line 1:
ORA-00957: duplicate column name

View 1 Replies View Related

Get A Query Of Each Sequence?

Jul 24, 2010

How do I get a query of each sequence and who has the permissions to it?

View 1 Replies View Related

SQL & PL/SQL :: Query To Update Duplicate Records?

Sep 20, 2011

The requirement is I have a table (TAB1), wherein I have 3 columns, ID, LID and STATUS.

The value in ID column = ID_SEQ.NEXTVAL,and LID will be either 0 or 1 and the possible values for STATUS are 'ED','CP', NULL. The ID column is not suppose to have duplicate values, but there is no check on the table for the same.

Someone has updated the existing data and ID column is containing duplicate values. Wherever LID = 0 and STATUS = NULL and if only if ID is duplicated then the ID_SEQ.NEXTVAL has to be assigned to ID field, so that there are no more duplicate values.

CREATE TABLE tab1 (id NUMBER , lid NUMBER, status VARCHAR2(10));

Existing Data
------------------
INSERT INTO tab1 VALUES (1,0, 'ED');
INSERT INTO tab1 VALUES (1,0, 'CP');
INSERT INTO tab1 VALUES (1,0, NULL);
INSERT INTO tab1 VALUES (1,0, NULL);
INSERT INTO tab1 VALUES (1,0, NULL);
INSERT INTO tab1 VALUES (1,0, NULL);

[code]....

get the result using a single update statement.

View 5 Replies View Related

SQL & PL/SQL :: How To Restrict Duplicate Values From Query

Sep 15, 2012

I have below query.. When i run this query i need to get two rows.. But i am getting two more duplicate rows.. I want to restrict these two rows..

How can i do this.. Here the problem is when i join B query then only i am getting duplicate rows..

SELECT DISTINCT B.TIC_ID, B.TIC_ISS_NO,
B.TIC_NUMBEC||CEV_ID,
B.TIC_NUMBEC, B.CEV_ID, B.AOSTED_DATE,
B.COMAANY_CODE, B.CONTCACTOC_NAME,
B.FC_CODE, B.C_NO, B.FC_TYAE,
[code].......

View 4 Replies View Related

SQL & PL/SQL :: Query To Get Sequence Number In Group

Dec 7, 2010

I have Table Data in format :-

--------------------------
ABC
ABC
ABC
XYZ
XYZ

and i have a requirement where I need the output in this format.

-------------
ABC 1
ABC 2
ABC 3
XYZ 1
XYZ 2

what query to be used for this

View 2 Replies View Related

SQL & PL/SQL :: How To Group Query Sequence Number Wise

Oct 3, 2010

I ve a data in table as follows

code status seqnce Length
B1 AVL 1 10
B2 AVL 2 10
B3 ASG 3 10
B4 AVL 4 10
B5 AVL 5 10
B6 AVL 6 10
B4 ASG 7 10
B4 ASG 8 10

I need to group the AVL status codes with the sum of lengths Ex) B1 to B2 - 20 B4 to B6 - 30 like that.

View 5 Replies View Related

Parallel Query ORA-01002 - Fetch Out Of Sequence

Feb 16, 2013

While executing parallel query we are getting the below errors.

(SQLState = HY010) - java.sql.SQLException: [tibcosoftwareinc][Oracle JDBC Driver][Oracle]ORA-01002: fetch out of sequence"
(SQLState = HY000) - java.sql.SQLException: [tibcosoftwareinc][Oracle JDBC Driver][Oracle]ORA-12842: Cursor invalidated during parallel execution

Database Version: Release 11.2.0.1.0 (Non-RAC)

SQL Query:
SELECT /*+ PARALLEL 4 */
DISTINCT
AI.STORE_ID STORE_ID, AI.DUE_DATE DUE_DATE, AI.INSTRUCTION_ID INSTRUCTION_ID,
DECODE (ASR.ADT_INSTR_KEY, NULL, 'F', ASR.ADT_INSTR_KEY, 'S') QCCHECK
FROM NSOAPP.DA_INSTRUCTION_INFO AI,
[code]....

View 4 Replies View Related

SQL & PL/SQL :: Tune Query Without Creating Any Objects Like Indexes?

Jan 14, 2013

Can we tune below mentioned query without creating any indexes :

SELECT /*+ PARALLEL(a,64) */x_abc_41, x_abc_44, CALLED_FROM_NUM, X_abc_25, created, evt_stat_cd, last_date, x_abc_number_from,
x_abc_complete_date
FROM table a
WHERE a.todo_cd in('MNPIN','MNPOUT')
AND a.x_abc_25 = 'NP RFS'
AND a.created BETWEEN sysdate-180 AND sysdate

Explain Plan :

PLAN_TABLE_OUTPUT
Plan hash value: 3718629559
----------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
----------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 11 | 2376 | 9462 (4)| 00:02:51 | | | |

[code]...

Note : Currently this query is taking 3 Minutes for retrieving 8000 records,But should be executed in less than 1 min.

View 11 Replies View Related

Forms :: Creating Alert After Records Retrieved From Query

Jun 26, 2013

I want to raise a alert after the records retrieved from a query. i.e, if the query fetches 0 records then the alert show be displayed. Is is possible? If yes tell me the trigger to be used to raise such kind of alert.

View 4 Replies View Related

SQL & PL/SQL :: How To Display Data Without Duplicate Records

Nov 16, 2011

how to display the data which is shown below without duplicate records in compid and compname and all policy_id's should be there while excuting this query iam getting this data.

select distinct comp_id as compid,
comp_disp_name as company,
plcy_id as policyid,

[Code]....

output
-----------------
compid compname policy_id policy_name

19734 Save the Children 9013 GPA
19734 Save the Children 9012 GMC
20097 JMT 9486 GTL
10890 Steelco Gujarat Ltd. 9727 CAR
17330 Golden Jubilee Hotels Limited 8915 CGL
23117 NBHC 9093 GMC
17542 Heinz India 10693 Fire
19821 KSK Fabricators 10341 D&O
3769 Jones Lang Lasalle India 9199 WC
19821 KSK Fabricators 10340 WC

View 10 Replies View Related

SQL & PL/SQL :: Remove Duplicate Data In Oracle-SQL

Mar 8, 2011

remove duplicate data in oracle-sql. can u post me the sql query to remove duplicate data with example.

View 1 Replies View Related

PL/SQL :: Find The Duplicate Data In Tables 11g

Feb 19, 2013

i want to find the duplicate data in my tables i have the below structure

SQL> desc x;
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
FILE_CODE                                          NUMBER(20)
STREAMNUMBER                                       VARCHAR2(50)
SERVICEKEY                                         VARCHAR2(50)
CALLINGPARTYNUMBER                                 VARCHAR2(50)
CALLEDPARTYNUMBER                                  VARCHAR2(50)
CHARGEPARTYINDICATOR                               VARCHAR2(50)

[Code] ......

i found the below query it's right

SELECT * x
WHERE ROWID NOT IN (SELECT MIN(ROWID) FROM x
GROUP by FILE_CODE,..........................,SEQ_NO ); all the column

View 7 Replies View Related

SQL & PL/SQL :: Same Sequence Number For Repeating Data

Feb 21, 2013

I want to insert same sequence number for repeated data else new sequence.

my data is as below

EMP_NAMEEMP_INV

PrasCTI
PrasCTI
ShariqWitness
KateCTI
ShariqAssisted
ShariqWitness

the first 2 record are same Pras CTI and Pras CTI so i want my sequence generate value once as below

1 Pras CTI
1 Pras CTI
2 Shariq Witness
3 Kate CTI
4 Shariq Assisted
2 Shariq Witness

Shariq and witness are repeating so same sequence number but Kate CTI occured once so nextval of sequence

How can i acivee it

CREATE TABLE EMP_INV
(
EMP_NAME VARCHAR2(100 BYTE),
EMP_INV VARCHAR2(100 BYTE)
)
Insert into EMP_INV
(EMP_NAME, EMP_INV)
Values
('Shariq', 'Witness');

[Code]...

View 12 Replies View Related

PL/SQL :: Sequence Of Data Generation Through Procedure?

Sep 11, 2012

I have a base table by name EMP_MASTER.The Create Statement goes something like this....

CREATE TABLE EMP_MASTER(ST_CODE NUMBER,EMP_CODE NUMBER);We would like to insert records in such a way that there are 10 st_codes and for each st_code we need to insert 100 records.

FOR EX : for st_code 1 we need to have emp_code from 1 to 100 and then we need to insert st_code 2 and the emp_code must be from 101 to 200 and so on...... It must go in this way till we have st_code 10 and hope the emp_code will be in the range of 901 to 1000.

We need some thing similar to proc or PL/SQL block(declare begin..... end)

View 5 Replies View Related

SQL & PL/SQL :: Creating PLSQL Collection Table Type With Dynamic Query?

Jul 12, 2013

How can I create PLSQL table type dynamically?

I will have to take the Employee Names and create a table structure. Number of employee names can vary from day to day. So, whenever I execute my procedure with Table type, I will have to build the table columns with the employee names.

View 2 Replies View Related

SQL & PL/SQL :: Creating Oracle Query To Fetch Information Using PIVOT Option?

Feb 27, 2013

creating Oracle SQL query to fetch the information using PIVOT option.We are populating audit table using triggers. For every update, there will be two rows into audit table, one row with all OLD values and another with all NEW values. Also every updated is uniquely identified by Sequence No. Example for phone audit is mentioned below :

CREATE TABLE test_audit_phone
(
emplid VARCHAR2(10),
seqno NUMBER,
action VARCHAR2(3),
office NUMBER,
mobile NUMBER
);

Insert some rows into table.

INSERT INTO test_audit_phone VALUES ('100',1,'OLD',1111,9999)
/
INSERT INTO test_audit_phone VALUES ('100',1,'NEW',2222,9999)
/
INSERT INTO test_audit_phone VALUES ('100',2,'OLD',2222,9999)
/
INSERT INTO test_audit_phone VALUES ('100',2,'NEW',2222,8888)
/

Table will look like the following :

SQL> SELECT * FROM sysadm.test_audit_phone ;

EMPLID SEQNO ACT OFFICE MOBILE
---------- ---------- --- ---------- ----------
100 1 OLD 1111 9999
100 1 NEW 2222 9999
100 2 OLD 2222 9999
100 2 NEW 2222 8888

Now we have to present data in different format. For each field, display OLD and NEW values in column format.

EMPLIDFIELDOLDNEW
----- ------ ---- -----
100OFFICE11112222
100MOBILE99998888

Challenges :

1) Make pivoting with old and new values

2) For each field we have to show old and new values

3)if old and new values are same, dont show in report.

View 8 Replies View Related

Forms :: Duplicate Check On Data Block

Jan 19, 2010

I wonder if there is some tiny technique to trace a duplicity on a block label without committing the records ( Maybe on Validate or new record instance)

I have one procedure to check duplicate but what I remember that there is something very smart provided from oracle to do that.

View 7 Replies View Related

SQL & PL/SQL :: How To Check And Delete Duplicate Data From Table

Nov 19, 2010

how i can chk & delete duplicate rows from a table

View 3 Replies View Related

SQL & PL/SQL :: Control Sequence To Return Same Value For Repeating Data?

Feb 13, 2013

how can i control the sequence to return same value for repeating data.

inter_no

10
10
11
12
12
13
14

what is required is as below

inter_no seq_val

10 1
10 1
11 2
12 3
12 3
13 4
14 5

is is on select statement will will insert the data once i get the sequence val is same for repeating one

View 5 Replies View Related

Data Guard :: Parameters With Active Duplicate For Physical Standby

Oct 17, 2012

We are planning to create physical standby database for 4-node RAC primary to a 4-node RAC standby using Active database duplicate with ASM and OMF

1. while using active database duplicate, do we need to set cluster_database=FALSE in spfile clause and create standby,next change it back to TRUE at standby. Or we don't need to touch it. And also do we need to include instance_number parameter
2. We are using OMF, can we use log_file_name_convert parameter in spfile clause of duplicate. Documentation says log_file_name_convert cannot be used if standby is going to have OMF. Because we have 5 groups for each thread, which are on 5 different disk groups. When standby is created all the logs are created in only one disk group pointed by db_create_online_file_dest_1.
3. To enable force logging at primary do we need to shutdown the database?

View 3 Replies View Related

Reports & Discoverer :: Showing The Number Sequence Of Displayed Data

Oct 21, 2010

I have query in that query i should display the number of row. I have tried to select the row num but when i use it the data will be duplicated. I have found something that related to use temporary table, or subquery but all of them will not work because the query depends on many tables and if i use temporary table filling the table and then reading from it will take too long time.

View 11 Replies View Related

Data Guard :: Generate Log Sequence 1 At Standby Database Everyday

Apr 21, 2011

We have standby dataguard set up namely CRMSTDY of 3 node RAC clusterware. It has been observed that log sequence number 1 is generated since last 4 days on standby database. There is nothing more information in alert_standby.log file and the same file is visible when we checked with ASMCMD utility. Check the attached print sceen and suggest. Below mentioned system information.

DB : Release 10.2.0.4.0
OS : Linux Enterprise release 5.2 (Carthage)

View 2 Replies View Related

PL/SQL :: Sql For Creating Xml Data

Nov 14, 2012

I have a requirement to create an xml file from a table. The table has product number repeated for each values of attrbiutes. Is it possible to create an xml file with product_id only once and all the attributes and values listed under that.

Example

WITH tmp AS
(SELECT '0983433' AS product, 'color' prd_attr, 'blue' AS val
FROM DUAL
UNION
SELECT '0983433' AS product, 'size' prd_attr, '23' AS val

[Code]...

And the file should be like the following

PRODUCTS>
- <PRODUCT>
<ID>0384491</ID>
- <NATURE>
<SALE>Y</SALE>

[Code]....

View 4 Replies View Related

Data Guard :: Error Occurred During Initial DB Duplicate To Standby Server?

Mar 20, 2008

i have setup the OEM-Dataguard in order to duplicate the DB instance from the primary to the standby DB in the standby server.At first I installed oracle server in Server A (Primary) created DB instance of SCT, in archivelog mode and then I install the oracle binary in Server B (standby) and made 2 servers ORACLE_HOME the same and also I installed OEM agents on the 2 servers and registered successfully to the OEM server.

I then used the dataguard to do the initial backup of the DB in server A and but when I specify the standby DB location, it prompt me the following error.

Error

Examine and correct the following error(s), then retry the operation.
Remote Operation Error - Internal error occured

Add Standby Database: Database Location

Primary Database SCT
Primary Host Ent
Step 3 of 6

Standby Database

* Instance Name The instance name (also referred to as the SID) must be unique on the standby host. Database Storage File SystemRaw Devices Choose whether the database files will be put on a conventional file system or on raw devices.

Standby Host Credentials

Enter the credentials of the user who owns the Oracle installation in the Oracle Home selected below.
* Username
* Password

Standby Database Location

The standby database can be created in any Oracle Home that has been discovered by Enterprise Manager. Only Oracle Homes on hosts that match the operating system of the primary host are shown. Select the Oracle Home in which to create the standby database.

Search For Host
Select Host Oracle Home Oracle Server Version Operating System Operating System Version
Ent /u01/app/oracle/product/10.2.0/db_1 10.2.0.1.0 SunOS 5.10
Ent_standby /u01/app/oracle/product/10.2.0/db_1 10.2.0.1.0 SunOS 5.10

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved