Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread ftBytes parameters
Fri, Jul 14 2017 11:06 AMPermanent Link

Mirco Malagoli

Hi,
in version 4.40 im not able to write the ftBytes anymore.
This is the simple code:
   TMemoryStream *ms = new TMemoryStream();
   ms->WriteBuffer( buf, sizeof(buf));
   ms->Position= 0;
   Q_write->Close();
   Q_write->ParamByName( "p1")->LoadFromStream( ms, ftBytes);
   Q_write->ExecSQL();
the field in the table is always filled with 0

If I use a table
   TAB_dati->Edit();
   TAB_dati->FieldByName( "l0")->SetData( buf, true);
   TAB_dati->Post();
the field is filled correctly
What can i do?
thanks!
Mon, Jul 17 2017 10:41 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mirco,

<< in version 4.40 im not able to write the ftBytes anymore. >>

What version were you using before ?  Did you change anything about the code, or were you using the exact same code ?

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 20 2017 6:02 AMPermanent Link

Mirco Malagoli

Sorry i forgot...
I use Builder2009 with 4.30
The code is exactly the same only update dbisam
Thanks

Tim Young [Elevate Software] wrote:

Mirco,

<< in version 4.40 im not able to write the ftBytes anymore. >>

What version were you using before ?  Did you change anything about the code, or were you using the exact same code ?

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 20 2017 11:05 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mirco,

<< Sorry i forgot...
I use Builder2009 with 4.30
The code is exactly the same only update dbisam >>

Okay, let me check it out and I'll see what might have changed to break this.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jul 26 2017 11:50 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mirco,

Sorry for the delay.  I'm looking into this issue, but I'm confused as to how you were even able to use the ftBytes field type with the LoadFromStream method.  The LoadFromStream method looks like this:

https://www.elevatesoft.com/manual?action=viewmethod&id=dbisam4&product=rsdelphiwin32&version=10T&comp=TDBISAMParam&method=LoadFromStream

(and has always looked like that)

The TBlobType makes sure that the LoadFromStream method only accepts TFieldType values for BLOB types.  The ftBytes enumerated type is *not* one of the BLOB types.

Is it possible that you used different code, or a different parameter method, for assigning the data ?  I suppose that it's possible that C++ doesn't enforce the type as strictly as Object Pascal, thus allowing the assignment.  However, the LoadFromStream method was never intended to be used with non-BLOB parameter types.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Jul 28 2017 3:48 AMPermanent Link

Mirco Malagoli

Tim Young [Elevate Software] wrote:

Mirco,

Sorry for the delay.  I'm looking into this issue, but I'm confused as to how you were even able to use the ftBytes field type with the LoadFromStream method.  The LoadFromStream method looks like this:

https://www.elevatesoft.com/manual?action=viewmethod&id=dbisam4&product=rsdelphiwin32&version=10T&comp=TDBISAMParam&method=LoadFromStream

(and has always looked like that)

The TBlobType makes sure that the LoadFromStream method only accepts TFieldType values for BLOB types.  The ftBytes enumerated type is *not* one of the BLOB types.

Is it possible that you used different code, or a different parameter method, for assigning the data ?  I suppose that it's possible that C++ doesn't enforce the type as strictly as Object Pascal, thus allowing the assignment.  However, the LoadFromStream method was never intended to be used with non-BLOB parameter types.

Tim Young
Elevate Software
www.elevatesoft.com


Yes, the LoadFromStream is only a try to see why the new version do not work.
The real code is:
         t= tableByte;   //memory table
         t->Open();
         t->Insert();
         t->Fields->Fields[0]->SetData( buf, true);

         qIns->ParamByName( param)->DataType= ftBytes;
         qIns->ParamByName( param)->AssignField( t->Fields->Fields[0] );

what method is the correct way to insert a ftByte?
Thanks!
Fri, Jul 28 2017 12:12 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mirco,

<< The real code is:  >>

Yeah, there's an issue with the way that ftBytes parameters are handled when the SQL is executed.  I will have a fix out for this soon, so make sure that you're signed up for build notifications.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Jul 28 2017 12:18 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mirco,

BTW, the hot fix is to replace the TDBISAMParam.AssignFieldValue method in the dbisamtb.pas unit with this one:

procedure TDBISAMParam.AssignFieldValue(Field: TField; const Value: Variant);
var
  P: Pointer;
  TempBuffer: pAnsiChar;
begin
  if (Field <> nil) then
     begin
     if (Field.DataType=ftString) and TStringField(Field).FixedChar then
        DataType:=ftFixedChar
     else if (Field.DataType=ftMemo) and (Field.Size > MAX_FIELD_SIZE) then
        DataType:=ftString
     else
        DataType:=Field.DataType;
     if VarIsNull(Value) then
        Clear
     else
        Self.Value:=Value;
     FBound:=True;
     end;
end;

The problem was with this method trying to change the ftBytes byte array into a normal buffer instead of just assigning the value directly (Self.Value:=Value line).

Tim Young
Elevate Software
www.elevatesoft.com
Image