Re: unique keys
Posted in 1997
try using a serial field instead of interger. Unless there is a need to have the interger null(which your statement states not null) the serial field\\ should fulfill your needs. --- ,-, |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ======= ___|| | | ----- //_ || | CANNON EXPRESS | ---- ,-----'| ~ | | | -- |o-----|__ |--`======_______________________________======___| ~~~~~~~~ `-(*)--===~~~~~~(*)(*)| (*)(*)| ------- ------------------------------------------------------------------------- Joseph Cullipher |E-mail: joseph@cannonexpress.com PO Box 364 |opinions express are those of my own and Springdale, AR 72764 USA |don't necessarily reflect those of my company ------------------------------------------------------------------------- On Mon, 17 Mar 1997, Barrou Diallo wrote: } Dear Informix/Illustra users. } } I have a problem to create rows with unique keys: I have created a } table like this: } } * create table pat } } ( } idpat integer not null primary key, } firstname text, -- Fisrt Letter Upper case, others in } lower } lastname text, -- Fisrt Letter Upper case, others in } lower } sex char, -- F|f or M|m } birthday date, -- Patient birthday } handedness char, -- L|l= Left R|r= Right } secunum char(20), -- Securite social num } info geninfo_t, -- general informations } } check ( handedness='L' or handedness='R' } or handedness='l' or handedness='r'), } check (sex='M' or sex='F' or sex='m' or sex='f') } } ); } } When I insert a new row manually, there is no problems: } } * insert into pat(idpat,firstname,lastname,sex,handedness) } values (0,'DIALLO','Barrou','M','R'); } } one row inserted } } } But when I attempt to insert automatically a new roaw with a incremental } idpat, the system fails : } } * insert into pat(idpat) } select MAX(idpat)+1 from pat; } XQ0002:Optimizer Internal Error: unknown node type } } } } } Have anyone an idea to correct this problem , or an other solution to } generate a unique key automaticlly. } } Thank you very much for your help. }