Subject SQL Error code 0 or 501
Author mw@wobe-team.com
Hi,

currently I'm facing some trouble with stored procedures.
On a heavy load system. I'm getting some errors wich are
I cannot explain.

My System:

Firebird 1.5.1
Windows XP P/2003 Server
Delphi 7E
IBO 4.3.Aa

Tools:

MemProof 0.9.4.8

1) sometimes I get an error without any
ISC or SQL Errornumber like:

2004 Oct 07 6:52:56 PM:WPS::ERROR:db error: SQL:0 ISC:0
2004 Oct 07 6:52:56 PM:WPS::ISC--> 0
2004 Oct 07 6:52:56 PM:WPS::ISC--> 0
2004 Oct 07 6:52:56 PM:WPS::SQL--> delete from ACTIVE_QUEUE_TAB
where ACTIVE_QUEUE_ID = ? /* id */

2004 Oct 07 6:52:56 PM:WPS:::<DeleteActiveQueueEntry> failed

What's this ???

2) MemProof shows a lot of errors (see attachment).
The calling code for the procedure in the Screenshot is:

function TAppCtrl.GetRootObject: integer;
var
sproc: TIB_StoredProc;
{$IFDEF DEBUG_VER}
c, n1, n2: TLargeInteger;
{$ENDIF}
begin
{$IFDEF DEBUG_VER}
QueryPerformanceFrequency(c);
QueryPerformanceCounter(n1);
{$ENDIF}
sproc := TIB_StoredProc.Create(nil);
sproc.IB_Connection := _ProdBase;
sproc.IB_Transaction := _ScriptTransaction;
sproc.OnError := _OnIBError;
sproc.Name := 'GET_OBJECT_ID';
sproc.StoredProcName := 'GET_OBJECT_ID';
try
with sproc do
begin
ParamByName('PARENTID').AsInteger := 0;
ParamByName('OBJ').AsString := '__rootlevel__';

ExecProc;

Result := ParamByName('OBJECTID').AsInteger;
if ParamByName('INSERTED').AsInteger <> 0 then
FNewObjectsCreated := True;
end;
except
sproc.Free;
raise;
end;

sproc.Free;
{$IFDEF DEBUG_VER}
QueryPerformanceCounter(n2);
WriteLog(Format('ƒƒ-> GetRootObject T = %g <-ƒƒ', [(n2 - n1) / c]));
{$ENDIF}

end;
//#---------------------------------------------------------------------

The DoTheFetch Method in IB_Components has some comments about a 'Bug' I do not
really understand this. Has this something to do with my Problems ?

..
// There seems to be a bug where a cursor on the server is not getting closed.
// Or, it could be getting opened when it should not be.
// Added code below to attempt to avoid/recover.
if ( errcode = 0 ) and Assigned( Out_DA ) then
isc_dsql_free_row_statement( @status, PstHandle, DSQL_CLOSE );
..
// There seems to be a bug where the server is losing the compile.
// Added code below to attempt to recover.
if ( errcode = isc_dsql_error ) or
( errcode = isc_port_len ) then
begin
if ClientMonitorHooksIn then
begin
MonitorText := '//>>> STATEMENT PREPARED <<<//'#13#10 +
'TIB_Statement.API_QuickFetch()'#13#10 +
'Recovery from lost server compile needed.'#13#10 +
Self.ClassName + ': "';
if Assigned( Self.Owner ) and ( Self.Owner.Name <> '' ) then
MonitorText := MonitorText + Self.Owner.Name + '.';
MonitorText := MonitorText + Self.Name +
'" stHandle=' + IntToStr(Integer(PstHandle^)) + ' #QF';
OutputToMonitor( MonitorText );
end;
if not StoredProcHasDML then
begin
asm fstcw [SaveCW] end;
tmperr := isc_dsql_prepare( @tmpstatus,
PtrHandle,
PstHandle,
null_terminated,
PChar(ServerSQL),
SQLDialect,
Out_DA );
asm fldcw [SaveCW] end;
if tmperr = 0 then
begin
asm fstcw [SaveCW] end;
DoTheFetch;
asm fldcw [SaveCW] end;
end;
end;
end;

Thanks in advance
Maik

To: firebird-support@yahoogroups.com
Cc: IBObjects@yahoogroups.com


[Non-text portions of this message have been removed]