joerg
User
 Fresh Boarder
| Posts: 1 |   | Karma: 0 |
|
Fill BLOB with Query via SQL statement
|
|
Posted: 2002/08/11 17:36 |
|
|
|
|
Hello.
I have really a great problem with my project.
I have created follow test table:
-- table definition drop table tblTest; create table tblTest (ID number(10), char_value char(10), varchar_value varchar2(20), number_value number(10,2), long_value long, date_value date, time_value date, blob_value blob);
-- NOT NULL Constraint for row ID alter table tblTest add constraint nn_TestID check(ID IS not Null);
-- row ID set as Primary Key alter table tblTest add constraint pk_TestID primary key (ID);
-- create Sequenz drop sequence seqtestid; CREATE SEQUENCE seqTestID INCREMENT BY 1 START WITH 1;
-- create Trigger drop trigger trgtestid_ins; CREATE or replace TRIGGER trgTestID_ins BEFORE INSERT ON tblTest FOR EACH ROW WHEN (new.id IS NULL) BEGIN SELECT seqTestID.nextval INTO :new.id FROM dual; END;
In the frontend I will read/write an char-, varchar-, number-, date-, time- and an image-value (JPG-Image). All database operations are done with SQL statements. If I try to insert my values over the frontend with button "SaveBtn" with follow code, then I become the error message "In project Oratest1.exe an exception of class EOCIDBError occured. Message: 'NOE10/VAR - Data is to large for variable'. Process stopped. ...".
Here the sample code:
procedure TForm1.SaveBtnClick(Sender: TObject); VAR DateStr, TimeStr : String; ms : TMemoryStream;
begin ms:=TMemoryStream.Create; Image1.Picture.Graphic.SaveToStream(ms); ms.Position:=0; DateStr:=DateToStr(DateTimePicker1.Date); TimeStr:=TimeToStr(DateTimePicker2.Time); DataModule1.OCIQuery1.DisableControls; WITH DataModule1.OCIQuery1 DO BEGIN SQL.Clear; SQL.Add('INSERT INTO tblTest (Char_Value, Varchar_Value, Number_Value, '); SQL.Add('Date_Value, Time_Value, Long_Value, Blob_Value) '); SQL.Add('VALUES (''' + Edit1.Text + ''', ''' + Edit2.Text + ''', ' + Edit3.Text + ', '); SQL.Add('''' + DateStr + ''', to_date(''' + TimeStr + ''',''HH24:MI S''), ''' + Memo1.Text + ''', '); SQL.Add(':BLOB_Value)'); ParamByName('BLOB_Value').LoadFromStream(ms,ftGraphic); TRY Prepare; Screen.Cursor:=crSQLWait; ExecSQL; Screen.Cursor:=crDefault; Edit1.Text:=''; Edit2.Text:=''; Edit3.Text:=''; Memo1.Text:=''; Image1.Picture:=Nil; EXCEPT Screen.Cursor:=crDefault; MessageDlg('Fehler bei Datenbankaktualisierung.'+#10#13+ 'Stellen Sie sicher, dass die Datenbank erreichbar ist.',mtError,[mbOK],0); EnableControls; END; Screen.Cursor:=crDefault; EnableControls; END; ms.Free; end;
If I use the same code with an standard ODBC connection and the originally delphi database and query components, then the code works fine. Data read goes with NCOCI8 and standard delphi components.
I use Delphi 5 Prof. SP 1
Have anybody an idea?
|
|