Re: SQL question, getting error and not sure why
| From: | Michael Davey | Date: | Thu, 30 May 2002 14:52:55 +0000 |
| Subject: | Re: SQL question, getting error and not sure why | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99931@lists.php.net to get a copy of this message | ||
> insert into acteursenc (nuacteur,nomacteur)
> (select AA, BB from
> (select max(nuacteur)+1 AA from acteursenc),
> (select 'Michael Sweeney' BB from acteursenc))"
>
> produces an ORA-00001: unique constraint error.
>
> The primary key is nuacteur, but by setting AA to max(nuacteur)+1 I should
> be getting a new key that is unique, however it does not seem that way.
>
> What am I doing wrong here?
I'm not an Oracle expert, but surely max(field) + 1 is one higher than the
maximum value possible for the column?
(Probably irrelevant snippet from mySQL manual:
MAX(expr)
Returns the minimum or maximum value of expr. MIN() and MAX() may take a
string argument; in such cases they return the minimum or maximum string
value.)
regards,
Mikey