Registriert seit: 31. Aug 2010
Ort: Schweiz
4 Beiträge
Delphi 7 Professional
|
Delphi & Oracle
1. Sep 2010, 18:18
end.
Habe in Oracle eine Procedure erstellt.
SQL-Code:
PROCEDURE UPDATE_TABLE (p_filename IN VARCHAR2)
IS
current_transaction_id INT := 0;
BEGIN
SELECT sn_tr_seq.NEXTVAL
INTO current_transaction_id
FROM DUAL;
INSERT INTO sosa_tools.serial_transaction
(transaction_id, filename, tr_date
)
VALUES (current_transaction_id, p_filename, SYSDATE
);
COMMIT;
END;
Daten aus dem ExcelFile in die Datenbank hinein schreiben und anzeigen funktioniert ganz gut.
Jedoch das Speichern von Filename in die Datenbank funktioniert leider nicht.
Bitte helft miiir! >.<
Delphi-Quellcode:
implementation
{$R *.dfm}
procedure TfMain.FormShow(Sender: TObject);
begin
Caption := AppVersion;
end;
procedure TfMain.Button1Click(Sender: TObject);
begin
loadExcel('C:\Development\Tools\SerialTracker\Data\08_27082010.xlsx');
end;
procedure TfMain.FormDestroy(Sender: TObject);
begin
if not VarIsEmpty(V) then
V.Quit;
end;
procedure TfMain.loadExcel(FileName: String);
var
exit : Boolean;
i : integer;
test : String;
MySettings: TformatSettings;
begin
MySettings.DateSeparator := '.';
MySettings.ShortDateFormat := 'dd.mm.yy';
V := CreateOleObject('Excel.Application');
V.Visible := True;
V.Workbooks.Open(FileName);
//ShowMessage(V.activeWorkbook.worksheets[1].Cells[1,1]);
dm.qSerialTracker.Close;
dm.qSerialTracker.Open;
//dm.qSerialTracker.Edit;
//dm.qSerialTracker.Insert;
//dm.qSerialTracker.FieldByName('order_no').AsString := V.activeWorkbook.worksheets[1].Cells[i,1];
// Dies funktioniert leider nicht..
dm.update_table_serial.ParamByName('p_filename').AsString := ('08_27082010.xlsx');
//Dieser Teil funktioniert
i := 1;
exit := False;
repeat
Inc(i);
test := V.activeWorkbook.worksheets[1].Cells[i, 1];
dm.sp_ins_sn_line.ParamByName('p_order_no').AsString := V.activeWorkbook.worksheets[1].Cells[i, 1];
dm.sp_ins_sn_line.ParamByName('p_digit8').AsString := V.activeWorkbook.worksheets[1].Cells[i, 2];
dm.sp_ins_sn_line.ParamByName('p_bezeichnung').AsString := V.activeWorkbook.worksheets[1].Cells[i, 3];
dm.sp_ins_sn_line.ParamByName('p_snr').AsString := V.activeWorkbook.worksheets[1].Cells[i, 4];
dm.sp_ins_sn_line.ParamByName('p_empfaenger').AsString := V.activeWorkbook.worksheets[1].Cells[i, 5];
dm.sp_ins_sn_line.ParamByName('p_adresse').AsString := V.activeWorkbook.worksheets[1].Cells[i, 6];
dm.sp_ins_sn_line.ParamByName('p_plz').AsString := V.activeWorkbook.worksheets[1].Cells[i, 7];
dm.sp_ins_sn_line.ParamByName('p_ort').AsString := V.activeWorkbook.worksheets[1].Cells[i, 8];
dm.sp_ins_sn_line.ParamByName('p_lieferdatum').AsDate := StrToDate(V.activeWorkbook.worksheets[1].Cells[i, 9], MySettings);
dm.sp_ins_sn_line.Execute;
test := V.activeWorkbook.worksheets[1].Cells[i + 1, 1];
until Length(test) = 0;
end;
Geändert von mkinzler ( 1. Sep 2010 um 18:23 Uhr)
Grund: Code-Tags durch SQL/Delphi-Tag ersetzt
|
|
Zitat
|