Page 1 of 1

Charset OCTETS and parameters

Posted: Mon 28 Mar 2011 12:29
by upscene
Hi,

I'm trying to move the byte values for a CHAR(16), charset OCTETS from one table to another by using a parameterized INSERT statement and setting the blob value.

However, this raises a "SQLcode -303, internal error" on .Execute of the insert.

The simplest version to reproduce is:

Code: Select all

var b: TBytes;
begin
  qrySrc.Open;
  qryDest.Prepare;
  while not qrySrc.EOF
  do begin
       b := qrySrc.Fields[0].AsBytes;
       qryDest.Params[0].SetBlobData(b, Length(b));
       qryDest.Execute;
       qrySrc.Next;
     end;
"qrySrc" has a SELECT FROM mytable
"qryDest" has an INSERT INTO mytable2 VALUES (:g)

How is this supposed to work? What's going on?


With regards,

Martijn Tonies
Upscene Productions

Posted: Mon 28 Mar 2011 14:53
by AndreyZ
Hello,

The SetBlobData method is used to work with BLOB fields. After calling it the DataType parameter property is assigned to ftBlob, that causes this error. To solve the problem, please use the following code:

Code: Select all

qryDest.Params[0].AsBytes := b;

Posted: Mon 28 Mar 2011 15:17
by upscene
Hmm, I thought I tried that already, apparently not. Seems to work, thanks.

Posted: Mon 28 Mar 2011 15:23
by AndreyZ
It is good to see that this problem was solved. If any other questions come up, please contact us.