Subject | Re: [firebird-support] Returning a value from a Stored Procedure |
---|---|
Author | Rik Barker |
Post date | 2006-05-19T10:25:50Z |
Hi Martijn,
Thanks for taking the time to reply.
stored procedure for 2 reasons. The first is because I wasn't sure which
database engine I was going to use and I wanted to code the classes without
getting caught up in SQL engine specifics. Secondly, because I was trying
to make that as thread / user safe as possible.
Obviously, there's a before insert trigger populating the ID field that I
didn't post in my last mail that increments the generator. I thought the
combination of trigger and stored procedure was going to be the best design.
Appreciate your thoughts.
Cheers,
Rik
Thanks for taking the time to reply.
>It's like a Delphi "get method" to get the value of a property that doesOk, that makes sense.
>all sorts of stuff and modifies the object behind the screens. Do you
>code that as well? I doubt it.
>If you are select-ing, return data, don't modify it.
> > INSERT INTO Artists (Name) VALUES (:NAME);It's been the one part of my design that's had me concerned. It's in a
> > SELECT gen_id(ARTISTS_ID_GEN,0) FROM RDB$DATABASE INTO :FoundID;
>
>This isn't multi-user safe.
stored procedure for 2 reasons. The first is because I wasn't sure which
database engine I was going to use and I wanted to code the classes without
getting caught up in SQL engine specifics. Secondly, because I was trying
to make that as thread / user safe as possible.
Obviously, there's a before insert trigger populating the ID field that I
didn't post in my last mail that increments the generator. I thought the
combination of trigger and stored procedure was going to be the best design.
>If someone else uses this procedure/code, an INSERT could occur betweenShould I be locking? Or is the design just rubbish?
>your INSERT and the next SELECT. You will get the wrong ID here, because
>the generated has been incremented.
Appreciate your thoughts.
Cheers,
Rik