Subject Re: [firebird-support] SP does not work at first time
Author Martijn Tonies
Hi,

> I use a lot of stored procedures in my app. Now I have detected an
> anormal behaviour only in one SP, I think that it is a bug of FB:
>
> The first time that I call this SP, it does not read the last value
> of a field.This value has been put by a previous update SQL statement
> in an open transaction.
>
> I do "rollback" and the second time that I try it, it works ok.
>
> Well, of course it can be a bug of my app, but I have revised the
> source and everything is ok.
>
> The ***surprise*** is that if I add a dummy variable into the SP,
> then it works ok.
>
>
> For example, in my SP I have added:
> ---------
>
> declare dummy integer;
> ---------
>
> And now everything works ok, if I remove it, then the SP fails. This
> variable is a dummy variable, it is not used in any part of the SP. I
> think that it is a bug of FB because I can reproduce the error only
> changing a trivial part of a SP (adding or removing the dummy
> variable).

Short answer: hogwash!

Long answer: probably a transaction thingy.

> I cannot publish the code to reproduce the error because it is not
> easy for me. I only want to know if somebody has a problem similar.

One other thing to take in account, did you modify this SP
before attempting to execute it? If so, it might have been
cached by the engine and you need to disconnect all existing
connections before executing it.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com