Subject RE: [firebird-support] Pulling my hair out..
Author Svein Erling Tysvær
>Look at the attached database.. there is only one stored procedure.. and very little data.. Only really one record..
>
>Start IB Expert.. run the stored Proc.. It will return Null.. (Not right)
>Run it again, and again after that, gives back the right value.. but
>always fails the first time..
>
>Any ideas? Am I doing something dumb?

The 'dumb' thing is that this list doesn't allow attachments, Gordon. So extract the text of the stored procedure (and possibly some table create and insert if required) and post it to this list (strip out parts that are irrelevant for your question, we don't want an SP of several thousand lines).

If your SP looks something like:

create MySP returns(a integer = ?) as
begin
a = (select coalesce(MyVariable, 0) from MySingularTable);
update or insert into MySingularTable(MyVariable)
values(gen_id(MyGenerator, 1));
suspend;
end

then this will of course return <null> if MySingularTable is empty (there's no row to select, so coalesce is not executed). Though I don't know whether your problem is similar to this or something completely different.

Set