Autor Beitrag
wettmasta
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Di 17.01.06 13:12 
Guten Tag,
ich hab folgendes Problem.
Ich möchte z.B. Word Dateien in ein BlobFeld unter Oracle speichern.
Das funktioniert soweit auch, nur beim auslesen mit einem Stream des Blobfeldes ist die länge des Streams immer nur 32k groß. Wenn die Datei kleiner ist, kann ich sie mir ohne Probleme anschauen, ist sie jedoch größer, keine Chance.

Ich arbeite mit der BDE, dort gibts es auch den Punkt Blobsize, dieser steht auf 32k. Das würde natürlich mein Problem eklären aber leider nicht beheben, denn die Maximalgröße dieses Feldes ist auf 1000k laut BDE beschränkt.

Hat jemand eine Idee?



Arbeitsumgebung:

Delphi5
Oracle8
BDE5.1

Mfg
wettmasta
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 17.01.06 13:22 
:welcome: in der EE

Einfacher Tipp:
Schmeiß die BDE raus. Wenn die Beschränkung 1000k beträgt und du damit nicht klar kommst, ist das ein klares KO für die BDE. Mal abgesehen davon, dass die BDE viele Kritiker hat (auch mich).

Die einzige Alternative (wenn es BDE sein muss) wäre, die Dateien nicht in einem BLOB zu speichern, sondern nur das Verzeichnis mit dem Dateinamen in einem Zeichenfeld.
Das hätte den Vorteil, dass man die Dateien bearbeiten kann, ohne die Datenbank zu bemühen.

Die bessere Lösung wären vernünftige Datenbank-Komponenten für Oracle. Ich verwende die von Allround Automations und bin sehr zufrieden.
wettmasta Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Di 17.01.06 14:56 
Danke für die schnelle Antwort!
Nur hab ich nun ein Problem mit dem einfürgen in die Datenbank.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
  anlagefile :=OpenDialog1.FileName;
  FileStream := TFileStream.Create(anlagefile, fmOpenRead);
  FileStream.Position := 0;
  LOB.CopyFrom(FileStream, FileStream.Size);

  OracleQuery1.Close;
  OracleQuery1.sql.Clear;
  OracleQuery1.SQL.Text := 'INSERT INTO Gefgrp (ID,image) VALUES (:pID,:lob)';
  OracleQuery1.DeclareVariable('pid',Count);



wie bekomme ich nu den 2 Parameter mit dem BlobFeld hin?

Moderiert von user profile iconUGrohne: Delphi-Tags hinzugefügt.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 17.01.06 15:18 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  OracleQuery1.Close;
  OracleQuery1.sql.Clear;
  OracleQuery1.SQL.Text := 'INSERT INTO Gefgrp (ID,image) VALUES (:pID,:lob)';
  OracleQuery1.DeclareVariable('pid',otInteger);
  OracleQuery1.DeclareVariable('lob',otBlob);
  OracleQuery1.SetVariable('pid',<DeinWert>);
  OracleQuery1.SetVariable('lob',<DeinWert>); // Habe ich so noch nicht gemacht, müsste aber richtig sein
  OracleQuery1.ExecSQL;

Alles ohne Gewähr, da ich mit Blobs noch nicht viel gemacht habe und das wenige ist schon ziemlich lange her.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Di 17.01.06 15:36 
Statt DeclareVariable + SetVariable kann man auch DeclareAndSet benutzen.

Den LobLocator bekommst du mit SetComplexVariable zugewiesen.

_________________
Bravery calls my name in the sound of the wind in the night...
wettmasta Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.01.06 08:03 
Guten morgen,
ich bin in der sache immer noch nicht weiter gekommen.

OracleQuery1.SetVariable('lob',<DeinWert>);

Wie bekomme ich da nun mein File rein bzw. den Loblocater, ich stehe voll aufm Schlauch...
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mi 18.01.06 08:13 
Ich schrieb doch bereits, das geht mit SetComplexVariable...

_________________
Bravery calls my name in the sound of the wind in the night...
wettmasta Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.01.06 08:19 
Ich weis, hab dann das hier probiert was aber auch nicht ging.

LOB := TLOBLocator.Create(Session, otBLOB);
Lob.LoadFromFile(anlagefile);
SetComplexVariable('image', LOB);
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mi 18.01.06 08:58 
Und was geht da nicht? Fehlermeldung?

_________________
Bravery calls my name in the sound of the wind in the night...
wettmasta Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.01.06 09:01 
Lob.LoadFromFile(anlagefile);

In dieser Zeile sagt er mir, TLobLocater: Invalid Handle
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mi 18.01.06 09:15 
Nimm mal statt TLobLocator.Create TLobLocator.CreateTemporary, Parameter siehe Doku

Dann aber nicht vergessen, den Locator wieder freizugeben, sonst hast nen Speicherleck.

_________________
Bravery calls my name in the sound of the wind in the night...
wettmasta Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.01.06 10:39 
Super vielen Dank Leute, nun kann ich endlich ganz leicht Dateien Speichern und laden.

Ich poste hier nochmal zusammenhängent wie man das macht..

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
procedure TfmMain.Save;
var
  LOB: TLOBLocator;
  anlagefile: String;
begin
  if (OpenDialog1.Execute) then
  begin
    anlagefile :=OpenDialog1.FileName;
  end;
  OracleQuery1.sql.Clear;
  OracleQuery1.SQL.ADD('INSERT INTO Gefgrp (ID,image) VALUES (:var1,:var2)');
  OracleQuery1.DeclareVariable('var1',otInteger);
  OracleQuery1.SetVariable('var1', 32);
  OracleQuery1.DeclareVariable('var2',otBlob);
  LOB := TLobLocator.CreateTemporary(OracleSession1, otBLOB,true);
  Lob.LoadFromFile(anlagefile);
  OracleQuery1.SetComplexVariable('var2', LOB);
  OracleQuery1.execute;
  LOB.Free;
end;

procedure TfmMain.Laden;
var
  LOB: TLOBLocator;
begin
  OracleQuery1.SQL.Clear;
  OracleQuery1.SQL.Add('select image from GEFGRP where ID = 30');
  OracleQuery1.Execute;
  LOB := OracleQuery1.LOBField('IMAGE');
  LOB.SaveToFile('C:\Test1.doc');
  OracleQuery1.free;
  LOB.Free;
end;


Nochmal vielen vielen dank, die Komponente ist echt stark

/edit
P.S. Es geht auch mit der BDE hab ich gerade gefunden.
Man muss einfach Qry.RequestLive := True setzen.
Dann ist es egal wie groß der Inhalt des Blobfeldes beim auslesen ist!!