Subject Re: [firebird-support] Bad design causing problems
Author Ann W. Harrison
Rik Barker wrote:
>
> I've got a problem inserting records ...
>
> Several of the tables need to only insert if the record isn't already
> there....

As everyone has said, you're going to have problems with
duplicate names. There are always going to be people with
the bad taste to share names. That said, there's nothing
wrong with a selectable stored procedure (other than
portability) and your procedure is easy to fix.

Change this line:

> SELECT ID FROM ARTISTS WHERE (Artists.Name = :NAME) INTO :FoundID;

To this:

SELECT MAX(ID) FROM ARTISTS WHERE (Artists.Name = :NAME) INTO :FoundID;


That will get rid of the "multiple rows in a singleton select" error.


Cheers,


Ann