Subject | Re: [IBDI] Stroed procedure help under interbase 6.0 .. |
---|---|
Author | Helen Borrie (Team JEDI) |
Post date | 2000-09-13T22:41:15Z |
At 10:46 AM 13-09-00 +0200, you wrote:
CREATE PROCEDURE NEW_CODE_HISTO
RETURNS (CODE VARCHAR(15))
AS
DECLARE VARIABLE TMPCODE VARCHAR(15);
DECLARE VARIABLE TMPSOCIETE VARCHAR(5);
BEGIN
UPDATE Compteur
SET Historique = historique + 1;
select cast(Historique as VARCHAR(15)) from compteur
into :TMPCODE;
select cast(s_code as VARCHAR(5)) from societe
into :TMPSOCIETE;
CODE=:TMPCODE||TMPSOCIETE; /* concatenator in Interbase is || not +
suspend;
END
Did you realise that this Stored Proc is not multi-user-safe?
If more than one user updates the row in Compteur at the same time, there
is no way to guarantee that the user running this procedure will return the
correct Code.
Regards,
Helen
All for Open and Open for All
InterBase Developer Initiative · http://www.interbase2000.org
___________________________________________________
Project JEDI · http://delphi-jedi.org
___________________________________________________
>When I call this stored procedure, the result value CODE is always equalTry this:
>to NULL !
CREATE PROCEDURE NEW_CODE_HISTO
RETURNS (CODE VARCHAR(15))
AS
DECLARE VARIABLE TMPCODE VARCHAR(15);
DECLARE VARIABLE TMPSOCIETE VARCHAR(5);
BEGIN
UPDATE Compteur
SET Historique = historique + 1;
select cast(Historique as VARCHAR(15)) from compteur
into :TMPCODE;
select cast(s_code as VARCHAR(5)) from societe
into :TMPSOCIETE;
CODE=:TMPCODE||TMPSOCIETE; /* concatenator in Interbase is || not +
suspend;
END
Did you realise that this Stored Proc is not multi-user-safe?
If more than one user updates the row in Compteur at the same time, there
is no way to guarantee that the user running this procedure will return the
correct Code.
Regards,
Helen
All for Open and Open for All
InterBase Developer Initiative · http://www.interbase2000.org
___________________________________________________
Project JEDI · http://delphi-jedi.org
___________________________________________________