Subject | Re: [IBDI] Stroed procedure help under interbase 6.0 .. |
---|---|
Author | Ann Harrison |
Post date | 2000-09-13T22:16:57Z |
At 10:46 AM 9/13/2000 +0200, Fabrice Vendé - INFOCOB wrote:
statements. I'm somewhat unclear on why there wasn't an
error when two strings were added, unless they could both
be converted to numbers - traditionally InterBase would do
things like that - but in that case there should have been
a result.
Helen continued
so this is multi-user safe. It may deadlock, but it won't
return wrong answers due to multi-user problems. Wonder why
it returned null....
Bemused,
Ann
>Helen Borrie responded
>When I call this stored procedure, the result value CODE is always equal
>to NULL !
>...
>.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;
> suspend;
>END
>CODE=:TMPCODE||TMPSOCIETE; /* concatenator in Interbase is || not +Which is OK, except for the ":" which is used only in SQL
statements. I'm somewhat unclear on why there wasn't an
error when two strings were added, unless they could both
be converted to numbers - traditionally InterBase would do
things like that - but in that case there should have been
a result.
Helen continued
>Did you realise that this Stored Proc is not multi-user-safe?All the actions in a procedure take place within a transaction,
>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.
so this is multi-user safe. It may deadlock, but it won't
return wrong answers due to multi-user problems. Wonder why
it returned null....
Bemused,
Ann