niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » IBM DB2
unique generated numbers
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
mob1012
*nix forums beginner


Joined: 18 Jul 2006
Posts: 2

PostPosted: Tue Jul 18, 2006 2:56 pm    Post subject: Re: unique generated numbers Reply with quote

Thank you - I'll try it

Serge Rielau wrote:
Quote:
create trigger comp_id_num
BEFORE update on component_master
REFERENCING NEW AS N for each row
SET component_id = Generate_unique()
Back to top
Serge Rielau
*nix forums Guru


Joined: 29 Apr 2005
Posts: 1583

PostPosted: Tue Jul 18, 2006 2:49 pm    Post subject: Re: unique generated numbers Reply with quote

create trigger comp_id_num
BEFORE update on component_master
REFERENCING NEW AS N for each row
SET component_id = Generate_unique()

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ondemandbusiness/conf2006/
Back to top
mob1012
*nix forums beginner


Joined: 18 Jul 2006
Posts: 2

PostPosted: Tue Jul 18, 2006 1:58 pm    Post subject: unique generated numbers Reply with quote

Hi all,
I am new to DB2 for windows and I have a question about generating unique
numbers for a primary key. I have decided to use the generate_unique()
statement in a trigger to create this number. I have written the trigger like
this:

create trigger comp_id_num
after update on component_master
for each row
insert into component_master (component_id) values (Generate_unique())

where component_master is the table name, component_id is the column and
primary key

I cannot use this because the trigger is not used until after update and the
primary key cannot be null before update. I don't know what to do. I thought
about stored procedures or functions, but I'm really not familiar with either.
Any help will be appreciated. Thank you.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Fri Nov 21, 2008 6:30 pm | All times are GMT
navigation Forum index » Databases » IBM DB2
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Constraint for two fields unique any order MargaretGillon@chromalloy PostgreSQL 5 Wed Jul 19, 2006 4:01 pm
No new posts No line numbers when debugging using gcc and gdb programmer HP-UX 2 Sat Jul 15, 2006 9:28 pm
No new posts Renaming primary and /or unique keys Jens Lenge Oracle 7 Thu Jul 13, 2006 6:59 pm
No new posts orainst.exe has generated errors (Oracle Forms 6i w/ Patc... Iris Oracle 2 Wed Jul 12, 2006 7:22 pm
No new posts no unique overrider errors... pastorom@gmail.com C++ 6 Mon Jul 10, 2006 9:54 pm

Home Loan | Mortgage Calculator | Mortgage Calculator | Web Advertising | WesternUnion
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2015s ][ Queries: 20 (0.1304s) ][ GZIP on - Debug on ]