Identity Column Not Coming in a sequence. Need Suggestion.
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.

««12

Identity Column Not Coming in a sequence.... Expand / Collapse
Author
Message
Posted 7/28/2008 12:05:22 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/29/2008 10:29:00 PM
Posts: 1, Visits: 9
Hi Vikas,

Yours->If u need sequence solution then u need to create a seperate table : sequence and write trigger (after insert on the table for which u wish to implement it and within this proc u need to implement the logic ). I have done it and if u want i can send u the code as well .


->Could you please help me to send your code to generate unique id to ....vs1000@rediffmail.com

subbu
Post #12267
Posted 7/28/2008 12:43:32 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Today @ 7:30:07 AM
Posts: 197, Visits: 611
Hello,

Yes, there is no direct/1-to-1 equivalent in Teradata for Oracle sequencers.

What you can do, is to write a simple trigger as follows:

Suppose we have table definition as follows:

CREATE TABLE Table1 (Sequence1 Integer, Col1 Integer, Col2 Integer);

And a temporary table as follows:

CREATE VOLATILE TABLE tempTable1 (CurrentMaxValue Integer) ON COMMIT PRESERVE ROWS;

And we have an INSERT TRIGGER on this table as follows:

- INSERT tempTable1 (CurrentMaxValue) SELECT Max(Sequence1) + 1 FROM Table1;
- UPDATE Table1 SET Sequence1 = tempTable1.CurrentMaxValue WHERE (add parameters from newly added row);
- Empty the temporary table tempTable1.

I haven't tried it, but it should work if it doesn't hit any INSERT trigger's limitation. HTH.

Regards,

Adeel
Post #12274
« Prev Topic | Next Topic »

««12

Reading This Topic Expand / Collapse
Active Users: 1 ( 1 guest, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 10:40pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.031. 7 queries. Compression Disabled.