Board index » delphi » Problems inserting a TMemo into an Interbase 5 table BLOB field with Delphi 4

Problems inserting a TMemo into an Interbase 5 table BLOB field with Delphi 4

We've got a problem with Delphi 4 Prof. and the InterBase Server 5.0.
While trying to INSERT or UPDATE an InterBase table with a TMemo field,
which is EMPTY, with Delphi 4 the application hangs with a GPF. The same
application compiled with Delphi 3 Prof. works fantastic (same code!!!).

The application does not hang when there is only one character in the
Memo-field.

Has anybody an idea or a workaround for the problem

Here are the code fragments:

SQL-Query in the sourcecode
=====================================================
   try
    with tmpQuery do begin
     Close;
     SQL.Clear;
     SQL.Add('SELECT MAX(' + fldFaAPAPNr + ') FROM ' + tblFaAP);
     SQL.Add('WHERE ' + fldFaAPAdrID + ' = ' +
ATF.AdressenQuery.FieldByName(fldAdrAdrID).asString);
     Open;
     tmpAPNr := FieldByName('MAX').asInteger + 1;

     Close;
     SQL.Clear;
     SQL.Add('INSERT INTO ' + tblFaAP + '(' + fldFaAPAdrID + ', ' +
                                              fldFaAPAPNr + ', ' +
                                              fldFaAPAnrede + ', ' +
                                              fldFaAPTitel + ', ' +
                                              fldFaAPVorname + ', ' +
                                              fldFaAPName + ', ' +
                                              fldFaAPAbteilung + ', ' +
                                              fldFaAPTelDW + ', ' +
                                              fldFaAPFax + ', ' +
                                              fldFaAPInfo + ', ' +
                                              fldFaAPGeschlecht + ')');
     SQL.Add('VALUES (' +
ATF.AdressenQuery.FieldByName(fldAdrAdrID).asString + ', ' +
                          IntToStr(tmpAPNr) + ', ''' +
                          NewFaAPForm.AnredeComboBox.Text + ''', ''' +
                          NewFaAPForm.TitelComboBox.Text + ''', ''' +
                          NewFaAPForm.VornameEdit.Text + ''', ''' +
                          NewFaAPForm.NameEdit.Text + ''', ''' +
                          NewFaAPForm.AbtEdit.Text + ''', ''' +
                          NewFaAPForm.DWEdit.Text + ''', ''' +
                          NewFaAPForm.FaxEdit.Text + ''', ' +
                          ':Info' + ', ''' +
                          tmpSex + ''')');
     Params[0].asMemo := NewFaAPForm.APInfoMemo.Text;
     ExecSQL;

RefreshFaAPQuery(ATF.AdressenQuery.FieldByName(fldAdrAdrID).asInteger);
    end; // with tmpQuery...
   finally
    tmpQuery.Free;
   end;

Metadata of the InterBase table
=====================================================
/* Extract Table FAAP */

/* Table: FAAP, Owner: SYSDBA */
CREATE TABLE FAAP (ADRID INTEGER NOT NULL,
        APNR INTEGER NOT NULL,
        ABTEILUNG VARCHAR(30) CHARACTER SET ISO8859_1,
        ANREDE VARCHAR(10) CHARACTER SET ISO8859_1,
        TITEL VARCHAR(20) CHARACTER SET ISO8859_1,
        VORNAME VARCHAR(40) CHARACTER SET ISO8859_1,
        NAME VARCHAR(40) CHARACTER SET ISO8859_1,
        TELDW VARCHAR(8) CHARACTER SET ISO8859_1,
        FAX VARCHAR(8) CHARACTER SET ISO8859_1,
        INFO BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET ISO8859_1,

        GESCHLECHT VARCHAR(1) CHARACTER SET ISO8859_1,
CONSTRAINT APNRIDX PRIMARY KEY (ADRID, APNR));

 

Re:Problems inserting a TMemo into an Interbase 5 table BLOB field with Delphi 4


I had this error in delphi 3 c/s as well. Somewhere in the BDE Borland
looses a pointer... ;-). The same error occurs on Oracle.

You could avoid this by testing if the memo contains some data and if
not do a
Query1.ParamByName('memofield').Clear;
Query1.ParamByName('memofield').datatype:=ftString; (or ftmemo)

This worked for me.

Stefan

On Sun, 11 Oct 1998 20:45:11 +0200, ADC GmbH <adc.g...@t-online.de>
wrote:

Quote
>We've got a problem with Delphi 4 Prof. and the InterBase Server 5.0.
>While trying to INSERT or UPDATE an InterBase table with a TMemo field,
>which is EMPTY, with Delphi 4 the application hangs with a GPF. The same
>application compiled with Delphi 3 Prof. works fantastic (same code!!!).

>The application does not hang when there is only one character in the
>Memo-field.

>Has anybody an idea or a workaround for the problem

>Here are the code fragments:

>SQL-Query in the sourcecode
>=====================================================
>   try
>    with tmpQuery do begin
>     Close;
>     SQL.Clear;
>     SQL.Add('SELECT MAX(' + fldFaAPAPNr + ') FROM ' + tblFaAP);
>     SQL.Add('WHERE ' + fldFaAPAdrID + ' = ' +
>ATF.AdressenQuery.FieldByName(fldAdrAdrID).asString);
>     Open;
>     tmpAPNr := FieldByName('MAX').asInteger + 1;

>     Close;
>     SQL.Clear;
>     SQL.Add('INSERT INTO ' + tblFaAP + '(' + fldFaAPAdrID + ', ' +
>                                              fldFaAPAPNr + ', ' +
>                                              fldFaAPAnrede + ', ' +
>                                              fldFaAPTitel + ', ' +
>                                              fldFaAPVorname + ', ' +
>                                              fldFaAPName + ', ' +
>                                              fldFaAPAbteilung + ', ' +
>                                              fldFaAPTelDW + ', ' +
>                                              fldFaAPFax + ', ' +
>                                              fldFaAPInfo + ', ' +
>                                              fldFaAPGeschlecht + ')');
>     SQL.Add('VALUES (' +
>ATF.AdressenQuery.FieldByName(fldAdrAdrID).asString + ', ' +
>                          IntToStr(tmpAPNr) + ', ''' +
>                          NewFaAPForm.AnredeComboBox.Text + ''', ''' +
>                          NewFaAPForm.TitelComboBox.Text + ''', ''' +
>                          NewFaAPForm.VornameEdit.Text + ''', ''' +
>                          NewFaAPForm.NameEdit.Text + ''', ''' +
>                          NewFaAPForm.AbtEdit.Text + ''', ''' +
>                          NewFaAPForm.DWEdit.Text + ''', ''' +
>                          NewFaAPForm.FaxEdit.Text + ''', ' +
>                          ':Info' + ', ''' +
>                          tmpSex + ''')');
>     Params[0].asMemo := NewFaAPForm.APInfoMemo.Text;
>     ExecSQL;

>RefreshFaAPQuery(ATF.AdressenQuery.FieldByName(fldAdrAdrID).asInteger);
>    end; // with tmpQuery...
>   finally
>    tmpQuery.Free;
>   end;

>Metadata of the InterBase table
>=====================================================
>/* Extract Table FAAP */

>/* Table: FAAP, Owner: SYSDBA */
>CREATE TABLE FAAP (ADRID INTEGER NOT NULL,
>        APNR INTEGER NOT NULL,
>        ABTEILUNG VARCHAR(30) CHARACTER SET ISO8859_1,
>        ANREDE VARCHAR(10) CHARACTER SET ISO8859_1,
>        TITEL VARCHAR(20) CHARACTER SET ISO8859_1,
>        VORNAME VARCHAR(40) CHARACTER SET ISO8859_1,
>        NAME VARCHAR(40) CHARACTER SET ISO8859_1,
>        TELDW VARCHAR(8) CHARACTER SET ISO8859_1,
>        FAX VARCHAR(8) CHARACTER SET ISO8859_1,
>        INFO BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET ISO8859_1,

>        GESCHLECHT VARCHAR(1) CHARACTER SET ISO8859_1,
>CONSTRAINT APNRIDX PRIMARY KEY (ADRID, APNR));

Re:Problems inserting a TMemo into an Interbase 5 table BLOB field with Delphi 4


Quote
On Sun, 11 Oct 1998 20:45:11 +0200, ADC GmbH <adc.g...@t-online.de> wrote:

[...]
Quote
>     Params[0].asMemo := NewFaAPForm.APInfoMemo.Text;

[...]

Try using the TParam.Assign method.

  Params[0].Assign(NewFaAPForm.APInfoMemo.Lines);

//////////////////////////////////////////////////////////////////////////
Steve Koterski                 "What is success in this world? I would say
Technical Publications         it consists of four simple things: to live
INPRISE Corporation            a lot, to love a lot, to laugh a lot, and
http://www.inprise.com/delphi  from it all, to learn a lot."
                                                     -- Richard J. Needham

Re:Problems inserting a TMemo into an Interbase 5 table BLOB field with Delphi 4


This is a bug and is fixed in DELPHI 4 inline.

T.Ramesh.

Quote
ADC GmbH wrote:
> We've got a problem with Delphi 4 Prof. and the InterBase Server 5.0.
> While trying to INSERT or UPDATE an InterBase table with a TMemo field,
> which is EMPTY, with Delphi 4 the application hangs with a GPF. The same
> application compiled with Delphi 3 Prof. works fantastic (same code!!!).

> The application does not hang when there is only one character in the
> Memo-field.

> Has anybody an idea or a workaround for the problem

> Here are the code fragments:

> SQL-Query in the sourcecode
> =====================================================
>    try
>     with tmpQuery do begin
>      Close;
>      SQL.Clear;
>      SQL.Add('SELECT MAX(' + fldFaAPAPNr + ') FROM ' + tblFaAP);
>      SQL.Add('WHERE ' + fldFaAPAdrID + ' = ' +
> ATF.AdressenQuery.FieldByName(fldAdrAdrID).asString);
>      Open;
>      tmpAPNr := FieldByName('MAX').asInteger + 1;

>      Close;
>      SQL.Clear;
>      SQL.Add('INSERT INTO ' + tblFaAP + '(' + fldFaAPAdrID + ', ' +
>                                               fldFaAPAPNr + ', ' +
>                                               fldFaAPAnrede + ', ' +
>                                               fldFaAPTitel + ', ' +
>                                               fldFaAPVorname + ', ' +
>                                               fldFaAPName + ', ' +
>                                               fldFaAPAbteilung + ', ' +
>                                               fldFaAPTelDW + ', ' +
>                                               fldFaAPFax + ', ' +
>                                               fldFaAPInfo + ', ' +
>                                               fldFaAPGeschlecht + ')');
>      SQL.Add('VALUES (' +
> ATF.AdressenQuery.FieldByName(fldAdrAdrID).asString + ', ' +
>                           IntToStr(tmpAPNr) + ', ''' +
>                           NewFaAPForm.AnredeComboBox.Text + ''', ''' +
>                           NewFaAPForm.TitelComboBox.Text + ''', ''' +
>                           NewFaAPForm.VornameEdit.Text + ''', ''' +
>                           NewFaAPForm.NameEdit.Text + ''', ''' +
>                           NewFaAPForm.AbtEdit.Text + ''', ''' +
>                           NewFaAPForm.DWEdit.Text + ''', ''' +
>                           NewFaAPForm.FaxEdit.Text + ''', ' +
>                           ':Info' + ', ''' +
>                           tmpSex + ''')');
>      Params[0].asMemo := NewFaAPForm.APInfoMemo.Text;
>      ExecSQL;

> RefreshFaAPQuery(ATF.AdressenQuery.FieldByName(fldAdrAdrID).asInteger);
>     end; // with tmpQuery...
>    finally
>     tmpQuery.Free;
>    end;

> Metadata of the InterBase table
> =====================================================
> /* Extract Table FAAP */

> /* Table: FAAP, Owner: SYSDBA */
> CREATE TABLE FAAP (ADRID INTEGER NOT NULL,
>         APNR INTEGER NOT NULL,
>         ABTEILUNG VARCHAR(30) CHARACTER SET ISO8859_1,
>         ANREDE VARCHAR(10) CHARACTER SET ISO8859_1,
>         TITEL VARCHAR(20) CHARACTER SET ISO8859_1,
>         VORNAME VARCHAR(40) CHARACTER SET ISO8859_1,
>         NAME VARCHAR(40) CHARACTER SET ISO8859_1,
>         TELDW VARCHAR(8) CHARACTER SET ISO8859_1,
>         FAX VARCHAR(8) CHARACTER SET ISO8859_1,
>         INFO BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET ISO8859_1,

>         GESCHLECHT VARCHAR(1) CHARACTER SET ISO8859_1,
> CONSTRAINT APNRIDX PRIMARY KEY (ADRID, APNR));

Other Threads