📄 zdirsql.pas
字号:
{ Listen to a specific event }
procedure TDirNotify.ListenTo(Event: string);
begin
SetStatus(nsNotImplemented);
end;
{ Stop listening to a specific event }
procedure TDirNotify.UnlistenTo(Event: string);
begin
SetStatus(nsNotImplemented);
end;
{ Generate a notify event }
procedure TDirNotify.DoNotify(Event: string);
begin
SetStatus(nsNotImplemented);
end;
{ Check a notifycation message }
function TDirNotify.CheckEvents: string;
begin
SetStatus(nsNotImplemented);
Result := '';
end;
{ TDirStoredProc }
constructor TDirStoredProc.Create;
begin
FLocFields := TStringList.Create;
FLocValues := TStringList.Create;
FBof := true;
FEof := true;
end;
destructor TDirStoredProc.Destroy;
begin
if Active then
Close;
FLocFields.Free;
FLocValues.Free;
inherited Destroy;
end;
function TDirStoredProc.CreateBlobObject: TDirBlob;
begin
Result := nil;
end;
procedure TDirStoredProc.Close;
begin
FLocFields.Clear;
FLocValues.Clear;
FActive := False;
FAffectedRows := 0;
FBof := true;
FEof := true;
FRecNo := 0;
SetStatus(qsNotImplemented);
end;
procedure TDirStoredProc.ExecProc;
begin
if Active then
Close;
SetStatus(qsNotImplemented);
FAffectedRows := 0;
end;
function TDirStoredProc.Field(FieldNum: Integer): string;
begin
Result := '';
end;
function TDirStoredProc.FieldAlias(FieldNum: Integer): ShortString;
var
P, I: Integer;
begin
Result := FieldName(FieldNum);
P := 0;
for I := 0 to FieldNum-1 do
if FieldName(I) = Result then
inc(P);
if P <> 0 then
Result := Result + '_' + IntToStr(P);
end;
function TDirStoredProc.FieldBuffer(FieldNum: Integer): PChar;
begin
Result := nil;
end;
function TDirStoredProc.FieldByName(FieldName: ShortString): string;
begin
Result := Field(FieldIndex(FieldName));
end;
function TDirStoredProc.FieldCount: Integer;
begin
Result := 0;
end;
function TDirStoredProc.FieldDataType(FieldNum: Integer): TFieldType;
begin
Result := ftUnknown;
end;
function TDirStoredProc.FieldDecimals(FieldNum: Integer): Integer;
begin
Result := 0;
end;
function TDirStoredProc.FieldIndex(FieldName: ShortString): Integer;
var
I, P: Integer;
Name, Num: string;
begin
Result := -1;
if FieldCount = 0 then
Exit;
for I := 0 to FieldCount-1 do
if FieldName = Self.FieldName(I) then
begin
Result := I;
Break;
end;
if Result <> -1 then
Exit;
Name := '';
Num := '';
P := LastDelimiter('_', FieldName);
if P > 0 then
begin
Name := Copy(FieldName,1,P-1);
Num := Copy(FieldName,P+1,10);
end else
Exit;
P := StrToIntDef(Num,0) + 1;
if P < 1 then
Exit;
for I := 0 to FieldCount-1 do
begin
if Name = Self.FieldName(I) then
Dec(P);
if P=0 then
begin
Result := I;
Exit;
end;
end;
end;
function TDirStoredProc.FieldIsNull(FieldNum: Integer): Boolean;
begin
Result := True;
end;
function TDirStoredProc.FieldMaxSize(FieldNum: Integer): Integer;
begin
Result := 0;
end;
function TDirStoredProc.FieldName(FieldNum: Integer): ShortString;
begin
Result := '';
end;
function TDirStoredProc.FieldSize(FieldNum: Integer): Integer;
begin
Result := 0;
end;
function TDirStoredProc.FieldType(FieldNum: Integer): Integer;
begin
Result := 0;
end;
function TDirStoredProc.FindNext: Boolean;
var
I: Integer;
begin
Result := False;
if FLocValues.Count = 0 then
Exit;
Next;
while not Eof do
begin
Result := True;
for I := 0 to FLocValues.Count-1 do
if Field(Integer(FLocValues.Objects[I])) <> FLocValues[I] then
Result := False;
if Result = False then
Break;
Next;
end;
end;
procedure TDirStoredProc.First;
begin
FRecNo := 0;
FBof := (RecordCount <= 0);
FEof := FBof;
end;
function TDirStoredProc.GetBof: Boolean;
begin
Result := FBof;
end;
function TDirStoredProc.GetEof: Boolean;
begin
Result := FEof;
end;
function TDirStoredProc.GetErrorMsg: ShortString;
begin
Result := '';
if not (FStatus in [qsTuplesOk, qsCommandOk]) and Assigned(Transact) then
Result := Transact.Error;
end;
function TDirStoredProc.GetPrepared: Boolean;
begin
Result := FPrepared;
end;
procedure TDirStoredProc.Go(Num: Integer);
begin
FRecNo := IIF(Num < (RecordCount-1), Num, RecordCount-1);
FRecNo := IIF(FRecno < 0, 0, FRecno);
FBof := (FRecNo < 0);
FEof := (FRecNo >= RecordCount);
end;
procedure TDirStoredProc.Last;
begin
FRecNo := IIF(RecordCount > 0, RecordCount-1, 0);
FBof := (RecordCount <= 0);
FEof := FBof;
end;
function TDirStoredProc.Locate(Params: string): Boolean;
var
I, N: Integer;
begin
Result := False;
SplitParams(Params, FLocFields, FLocValues);
if FLocValues.Count = 0 then
Exit;
for I := FLocValues.Count-1 downto 0 do
begin
if IsDigit(FLocFields[I][1]) then
N := StrToIntDef(FLocFields[I],-1)
else
N := FieldIndex(FLocFields[I]);
if (N < 0) or (N >= FieldCount) then
begin
FLocFields.Delete(I);
FLocValues.Delete(I);
end
else
FLocFields.Objects[I] := TObject(N);
end;
First;
while not Eof do
begin
Result := True;
for I := 0 to FLocValues.Count-1 do
if Field(Integer(FLocFields.Objects[I])) <> FLocValues[I] then
begin
Result := False;
Break;
end;
if Result then
Break;
Next;
end;
end;
procedure TDirStoredProc.Next;
begin
FBof := False;
if FRecNo < (RecordCount-1) then
begin
Inc(FRecNo);
FEof := False;
end
else
FBof := True;
if RecordCount <= 0 then
begin
FBof := True;
FEof := True;
end;
end;
procedure TDirStoredProc.Open;
begin
if Active then
Close;
FAffectedRows := 0;
SetStatus(qsNotImplemented);
end;
function TDirStoredProc.Param(ParamNum: Integer): string;
begin
Result := '';
end;
function TDirStoredProc.ParamAlias(ParamNum: Integer): ShortString;
var
I, P: Integer;
begin
Result := ParamName(ParamNum);
P := 0;
for I := 0 to ParamNum-1 do
if ParamName(I) = Result then
Inc(P);
if P <> 0 then
Result := Result + '_' + IntToStr(P);
end;
function TDirStoredProc.ParamBuffer(ParamNum: Integer): PChar;
begin
Result := nil;
end;
function TDirStoredProc.ParamByName(ParamName: ShortString): string;
begin
Result := Param(ParamIndex(ParamName));
end;
function TDirStoredProc.ParamCount: Integer;
begin
Result := 0;
end;
function TDirStoredProc.ParamDataType(ParamNum: Integer): TFieldType;
begin
Result := ftUnknown;
end;
function TDirStoredProc.ParamDecimals(ParamNum: Integer): Integer;
begin
Result := 0;
end;
function TDirStoredProc.ParamIndex(ParamName: ShortString): Integer;
var
I, P: Integer;
Name, Num: string;
begin
Result := -1;
if ParamCount = 0 then
Exit;
for I := 0 to ParamCount-1 do
if ParamName = Self.ParamName(I) then
begin
Result := I;
Break;
end;
if Result <> -1 then
Exit;
Name := '';
Num := '';
P := LastDelimiter('_', ParamName);
if P > 0 then
begin
Name := Copy(ParamName,1,P-1);
Num := Copy(ParamName,P+1,10);
end else
Exit;
P := StrToIntDef(Num,0) + 1;
if P <= 1 then
Exit;
for I := 0 to ParamCount-1 do
begin
if Name = Self.ParamName(I) then
Dec(P);
if P = 0 then
begin
Result := I;
Exit;
end;
end;
end;
function TDirStoredProc.ParamIsNull(ParamNum: Integer): Boolean;
begin
Result := True;
end;
function TDirStoredProc.ParamMaxSize(ParamNum: Integer): Integer;
begin
Result := 0;
end;
function TDirStoredProc.ParamName(ParamNum: Integer): ShortString;
begin
Result := '';
end;
function TDirStoredProc.ParamSize(ParamNum: Integer): Integer;
begin
Result := 0;
end;
function TDirStoredProc.ParamType(ParamNum: Integer): Integer;
begin
Result := 0;
end;
procedure TDirStoredProc.Prepare(Params: TParams);
begin
SetPrepared(True);
end;
procedure TDirStoredProc.Prev;
begin
FEof := False;
if FRecNo > 0 then
begin
Dec(FRecNo);
FBof := False;
end
else
FBof := True;
if RecordCount <= 0 then
begin
FBof := True;
FEof := True;
end;
end;
function TDirStoredProc.RecordCount: Integer;
begin
Result := 0;
end;
procedure TDirStoredProc.SetActive(Value: Boolean);
begin
FActive := Value;
end;
procedure TDirStoredProc.SetAffectedRows(Value: Integer);
begin
FAffectedRows := Value;
end;
procedure TDirStoredProc.SetBof(Value: Boolean);
begin
FBof := Value;
end;
procedure TDirStoredProc.SetEof(Value: Boolean);
begin
FEof := Value;
end;
procedure TDirStoredProc.SetPrepared(const Value: Boolean);
begin
FPrepared := Value;
end;
procedure TDirStoredProc.SetRecNo(Value: Integer);
begin
FRecNo := Value;
end;
procedure TDirStoredProc.SetStatus(Value: TDirQueryStatus);
begin
FStatus := Value;
end;
procedure TDirStoredProc.ShowParams(StoredProcedureName: ShortString);
begin
if Active then
Close;
SetStatus(qsNotImplemented);
end;
procedure TDirStoredProc.ShowStoredProcs;
begin
if Active then
Close;
SetStatus(qsNotImplemented);
end;
function TDirStoredProc.StringToSql(Value: string): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Length(Value) do
if Value[I] = '''' then
Result := Result + ''''''
else
Result := Result + Value[I];
end;
procedure TDirStoredProc.UnPrepare;
begin
SetPrepared(False);
end;
function TDirStoredProc.GetReturnValue: string;
begin
Result := '';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -