![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » DBISAM Technical Support » Incident Reports » Incident Reports Reported for Version 4.04 » View Incident Report |
![]() |
Reported By: Danny Humphress Reported On: 3/17/2004 For: Version 4.04 Build 1 |
function TForm1.StatusCount( ADatabasePath: string): integer; var LocalSession: TDBISAMSession; LocalDatabase: TDBISAMDatabase; LocalQuery: TDBISAMQuery; begin LocalSession:=GetNewSession; try LocalDatabase:=TDBISAMDatabase.Create(nil); try with LocalDatabase do begin // Be sure to assign the same session name // as the TDBISAMSession component SessionName := LocalSession.SessionName; DatabaseName := 'subquery'; Directory := ADatabasePath; Connected := True; end; LocalQuery:=TDBISAMQuery.Create(nil); try with LocalQuery do begin // Be sure to assign the same session and // database name as the TDBISAMDatabase // component SessionName := LocalSession.SessionName; DatabaseName := LocalDatabase.DatabaseName; SQL.Clear; SQL.Add('SELECT COUNT(*) AS TheCount FROM InvCtrl '+ 'WHERE Number=110000'); try Open; Result := FieldByName('TheCount').AsInteger; except Result := 0; end; end; finally LocalQuery.Free; end; finally LocalDatabase.Free; end; finally LocalSession.Free; end; end; procedure TForm1.DBISAMEngine2CustomFunction(Sender: TObject; const FunctionName: String; FunctionParams: TDBISAMParams; var Result: Variant); begin if (AnsiCompareText(FunctionName,'StatusCount')=0) then begin try Result := StatusCount(FunctionParams[0].AsString); except on E:Exception do Result := null; end; end end; procedure TForm1.FormCreate(Sender: TObject); begin with DBISAMEngine2.Functions.CreateFunction(ftInteger, 'StatusCount').Params do begin CreateFunctionParam(ftString); // local database path end; LastSessionValue:=0; InitializeCriticalSection(SessionNameSection); end; function TForm1.GetNewSession: TDBISAMSession; begin EnterCriticalSection(SessionNameSection); try Result:=TDBISAMSession.Create(nil); with Result do SessionName:='AccountSession1'; finally LeaveCriticalSection(SessionNameSection); end; end; procedure TForm1.Button1Click(Sender: TObject); begin DBISAMQuery1.SQL.Text := 'SELECT StatusCount(''c:\temp'',110000,''#CC'') FROM Test'; DBISAMQuery1.Active:=True; end;
This web page was last updated on Wednesday, October 30, 2024 at 11:41 AM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |