Skip to main content
Question

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


perry
Forum|alt.badge.img+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

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • January 31, 2017

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.


Forum|alt.badge.img+7

 

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

 


david_r
Evangelist
  • January 31, 2017
jeroenstiers wrote:

 

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?

perry
Forum|alt.badge.img+2
  • Author
  • January 31, 2017

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?


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • January 31, 2017
perry wrote:

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.

 

 


Forum|alt.badge.img+7

does row_number() over() work?

That should give you a unique value for every row.


perry
Forum|alt.badge.img+2
  • Author
  • February 1, 2017

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings