sql >> Database >  >> RDS >> Mysql

Retourwaarde van opgeslagen functies in MyDAC

Hier is de code die we gebruiken om opgeslagen procedures aan te roepen - ik hoop dat het helpt

function TDbControl.DatabaseStoredProc(FConnectionsAddr: integer; SpName: string;var Params: TDAParams): boolean;
var
  MyStoredProc: TMyStoredProc;
  PramsTxt: String;
  Idx, Idx2: Integer;
begin
  result := False;
  MyStoredProc := nil;
  try
    try
      MyStoredProc := TMyStoredProc.Create(nil);
      MyStoredProc.Connection := TMyConnection(FConnectionsAddr);
      MyStoredProc.StoredProcName := SpName;
      MyStoredProc.ParamCheck := False;
      if assigned(Params) then
      begin
        for Idx := 0 to Params.Count - 1 do
        begin
            MyStoredProc.ParamByName(Params[Idx].Name).DataType := Params[Idx].DataType;
            MyStoredProc.ParamByName(Params[Idx].Name).Value := Params[Idx].Value;
        end;
      end;
      MyStoredProc.Execute;
      if assigned(Params) then
      begin
        for Idx := 0 to Params.Count - 1 do
        begin
         if (Params[Idx].ParamType =  ptOutput ) then
            Params[Idx].Value := MyStoredProc.ParamByName(Params[Idx].Name).Value;
        end;
      end;
      result := True;
    except
      on E: Exception do
      begin
        PramsTxt := '';
        if assigned(Params) then
        begin
          for Idx2 := 0 to Params.Count - 1 do
          begin
            PramsTxt := PramsTxt + Params.Items[Idx2].Name + '=' + Params[Idx2].AsString + ',';
          end;
        end;
        LogText(FConnectionsAddr, 'DatabaseStoredProc Err:' + E.Message + '  SpName:' + SpName + '  Prams:' + PramsTxt);
        raise ;
      end;
    end;
  finally
    FreeAndNil(MyStoredProc);
  end;
end;



  1. Gegevens invoegen en ophalen in MySQL met behulp van PHP via Ajax

  2. Functie of procedure voor een IN-clausule

  3. Toegangsformulier trapsgewijze keuzelijst toont niets in het vervolgkeuzemenu

  4. Hoe kan ik stemmen per dag per IP beperken in Php+Mysql-stemmen?