Subject Code Example 2: RB End user with IBO Stored Procs.
Author John Tomaselli
To all on this list that use End User Reports from DM's Report Builder. The
following code allows the end-user exe to bring up stored procs that return
a result set. Note, you can't have any parameters in the stored procedure
for this to work. All other features work like it's a table or view. Pretty
cool.
Chaged the code to only bring back sp's that return a result list.

John

Unit daIBO

procedure TdaIBOSession.GetTableNames(const aDatabaseName: String; aList:
TStrings);
var
lDatabase: TIB_Connection;
i: integer;
sProcName: string;
InputprocParamNames: TIB_StringList;
begin
{get the database}
lDatabase := daGetIBODatabaseForName(aDatabaseName);

{connection must be active to get table names}
if not lDatabase.Connected then
lDatabase.Connected := True;

InputprocParamNames:= TIB_StringList.Create;

try

if lDatabase.Connected then begin
alist.Assign(lDatabase.SchemaCache.TableNames);
alist.AddStrings( lDatabase.SchemaCache.ViewNames ); //added by greater
than zero for views
//added by greater than zero for stored procs with a result dataset
{ get rid of sp's
1. with an input param
2. no outputs
}
for i:= 0 to lDatabase.SchemaCache.ProcedureNames.Count - 1 do begin
sProcName:= lDatabase.SchemaCache.ProcedureNames[i];
lDatabase.SchemaCache.GetProcedureParamNames(sProcName, true,
InputprocParamNames);
if(InputprocParamNames.Count = 0) then begin
InputprocParamNames.clear;
// only procedures with no input parameters
lDatabase.SchemaCache.GetProcedureParamNames(sProcName, false,
InputprocParamNames);
if(InputprocParamNames.Count > 0) then
// only procedures with no input parameters AND > 0 number
of output
alist.Add(lDatabase.SchemaCache.ProcedureNames[i]);
end else
InputprocParamNames.clear;
end;

end;

except
InputprocParamNames.free;
end;

end; {procedure, GetTableNames}