Question

Create a unique key on a item in a oracle table based on the description,Hello,

  • 31 January 2017
  • 7 replies
  • 5 views

Badge +2

Hello,

I'm extracting data from a Oracle table to create a new table with codes such as:

Table name: Routers

Desc

Router Hall

Router Room156

Router Shelter

...

I want to add a unique key to identify the separate routers.

(I have tried COUNTER, CRCCalculator, attributecreater etc). Is there a simple way to create unique number these routers?


7 replies

Userlevel 2
Badge +16

You can use the SQLCreator instead of an Oracle reader and have the database create the unique number using a SQL statement like:

Select rownum, desc, router hall etc from Routers;

The rownum will give you a sequence number per records.

Badge +7

 

I am wondering. What part was not simple when using the Counter?

 

Userlevel 4

 

I am wondering. What part was not simple when using the Counter?

 

I agree. If neither the Counter or the CRCCalculator works, it seems we're missing some info. What is the error message? What data type should the unique id have?
Badge +2

Hi all, thanks for your input.

I'm extracting data from sqlserver.

Sqlcreator ic ROWNUM will give an error

 

'Provider error `(-2147217900) Invalid column name 'ROWNUM'.

I'm trying to make a table as follows:

 

TYPE ID(number) DESC

 

RESULT 0 FORCED NOT READY

 

RESULT 1 ABANDONED

RESULT 2 ANSWERED

 

RESULT 9 ONBEKEND

 

EVENT 0 CallEnd

 

EVENT 1 FNR

 

EVENT 2 Incoming

.....

 

I use several SQLCREATORS to extract data from sqlserver.

Type: a new attribute I create

ID: a unique number per TYPE

DESC: the data I extract from several dbo,[] from the sqlserver.

CRCCalculator will not give me an ID as specified and I did not succeed with Counter.

Perhaps there is a better way to do this?

Userlevel 2
Badge +16

Hi all, thanks for your input.

I'm extracting data from sqlserver.

Sqlcreator ic ROWNUM will give an error

 

'Provider error `(-2147217900) Invalid column name 'ROWNUM'.

I'm trying to make a table as follows:

 

TYPE ID(number) DESC

 

RESULT 0 FORCED NOT READY

 

RESULT 1 ABANDONED

RESULT 2 ANSWERED

 

RESULT 9 ONBEKEND

 

EVENT 0 CallEnd

 

EVENT 1 FNR

 

EVENT 2 Incoming

.....

 

I use several SQLCREATORS to extract data from sqlserver.

Type: a new attribute I create

ID: a unique number per TYPE

DESC: the data I extract from several dbo,[] from the sqlserver.

CRCCalculator will not give me an ID as specified and I did not succeed with Counter.

Perhaps there is a better way to do this?

Your previous question mentioned Oracle and in that case rownum can be used.

 

I do not know the SQL Server equivalent.

 

 

Badge +7

does row_number() over() work?

That should give you a unique value for every row.

Badge +2

YES !!!

I made the following query on SQL server and this works good:

SELECT 'EVENT' as TYPE,

 

ROW_NUMBER() OVER (ORDER BY [EventType] ASC) AS ID,

 

[EventType] AS DISCRIPTION

 

from

 

dbo.[RawHistData_RouterAgentDataView]

 

group by [EventType]

 

order by 1

Thank you all for the great help.

Reply