![]() |
AW: Stored Procedure: Rückgabewert
Hi,
das Ganze sieht dann nun so aus (und funktioniert auch):
Delphi-Quellcode:
Ist das dann so ok?
var
proc: TIBCStoredProc; ta: TIBCTransaction; begin ta := TIBCTransaction.Create(nil); ta.DefaultConnection := ibc_mainDB; proc := TIBCStoredProc.Create(nil); proc.Transaction := ta; proc.StoredProcName := 'CREATECUSTOMER'; proc.Prepare; proc.ParamByName('name').Value := custName; proc.ParamByName('title').Value := title; proc.ParamByName('forename').Value := forename; proc.ParamByName('surname').Value := surname; proc.ParamByName('street').Value := street; proc.ParamByName('houseNo').Value := houseNo; proc.ParamByName('country').Value := Uppercase(country); proc.ParamByName('zipcode').Value := zipcode; proc.ParamByName('cityname').Value := cityname; proc.ExecProc; result := proc.ParamByName('contactid').AsInteger; proc.Close; ta.Commit; proc.Free; ta.Free; end; LG, Frederic |
AW: Stored Procedure: Rückgabewert
Sieht ganz gut aus. Ich würde noch das Close weg geben und ein sauberes Exception-Handling machen. In etwa so:
Delphi-Quellcode:
Thomas
var
proc: TIBCStoredProc; ta: TIBCTransaction; begin ta := TIBCTransaction.Create(nil); ta.DefaultConnection := ibc_mainDB; proc := TIBCStoredProc.Create(nil); proc.Transaction := ta; try ta.StartTransaction; try proc.StoredProcName := 'CREATECUSTOMER'; proc.Prepare; proc.ParamByName('name').Value := custName; proc.ParamByName('title').Value := title; proc.ParamByName('forename').Value := forename; proc.ParamByName('surname').Value := surname; proc.ParamByName('street').Value := street; proc.ParamByName('houseNo').Value := houseNo; proc.ParamByName('country').Value := Uppercase(country); proc.ParamByName('zipcode').Value := zipcode; proc.ParamByName('cityname').Value := cityname; proc.ExecProc; result := proc.ParamByName('contactid').AsInteger; ta.Commit; except ta.Rollback; raise; end; finally proc.Free; ta.Free; end; end; |
AW: Stored Procedure: Rückgabewert
Dankeschön!
|
AW: Stored Procedure: Rückgabewert
kleine Korrektur...
Delphi-Quellcode:
var
proc: TIBCStoredProc; ta: TIBCTransaction; begin ta := TIBCTransaction.Create(nil); proc := TIBCStoredProc.Create(nil); try proc.Transaction := ta; ta.DefaultConnection := ibc_mainDB; ta.StartTransaction; try proc.StoredProcName := 'CREATECUSTOMER'; proc.Prepare; proc.ParamByName('name').Value := custName; proc.ParamByName('title').Value := title; proc.ParamByName('forename').Value := forename; proc.ParamByName('surname').Value := surname; proc.ParamByName('street').Value := street; proc.ParamByName('houseNo').Value := houseNo; proc.ParamByName('country').Value := Uppercase(country); proc.ParamByName('zipcode').Value := zipcode; proc.ParamByName('cityname').Value := cityname; proc.ExecProc; result := proc.ParamByName('contactid').AsInteger; ta.Commit; except ta.Rollback; raise; end; finally proc.Free; ta.Free; end; end; |
AW: Stored Procedure: Rückgabewert
Hi,
ich krieg die Krise. Ich hatte den Code von omata übernommen und das hatte auch alles geklappt. Seit eben kommt aber bei allem was ich tue (auch bei einer anderen Methode) nur noch folgende Fehlermeldung: Zitat:
Der Code im Moment:
Delphi-Quellcode:
var
proc: TIBCStoredProc; ta: TIBCTransaction; query: TIBCQuery; i, contactid: Integer; begin ta := TIBCTransaction.Create(nil); proc := TIBCStoredProc.Create(nil); query := TIBCQuery.Create(nil); result := True; try ta.DefaultConnection := ibc_mainDB; proc.Transaction := ta; query.Transaction := ta; ta.StartTransaction; try proc.StoredProcName := 'CREATECUSTOMER'; proc.Prepare; proc.ParamByName('name').Value := custName; proc.ParamByName('title').Value := title; proc.ParamByName('forename').Value := forename; proc.ParamByName('surname').Value := surname; proc.ParamByName('street').Value := street; proc.ParamByName('houseNo').Value := houseNo; proc.ParamByName('country').Value := Uppercase(country); proc.ParamByName('zipcode').Value := zipcode; proc.ParamByName('cityname').Value := cityname; proc.ExecProc; contactid := proc.ParamByName('contactid').AsInteger; query.SQL.Text := 'INSERT INTO DIALNUMBER (NUMBERTYPE, NUMBER, CONTACTID) VALUES (:type, :no, :contactid)'; query.Prepare; for i := 0 to length(dialNo) - 1 do begin query.ParamByName('type').Value := dialNo[i][0]; query.ParamByName('no').Value := dialNo[i][1]; query.ParamByName('contactid').Value := contactid; query.Execute; end; ta.Commit; except result := False; ta.Rollback; raise; end; finally query.Free; proc.Free; ta.Free; end; end; Was mache ich falsch? Es tritt auch bei den Codes von Thomas und omata auf. Ich muss also irgendwo was generelles verdreht haben, aber ich weiß nicht was?! Neustart half auch nicht. LG, Frederic |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:38 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz