Subject Re: [IBO] Problem with param value
Author Helen Borrie (TeamIBO)
At 03:53 PM 31-07-02 +0200, you wrote:
>i have one problem:
>
>i need a query for a table, which is created automatically
>(for any table structure)
>
>for example
>
>select id,field1,field2,field3 from tbl where id=123
>
>this is opened in q1:TIB_Query
>
>
>
>with the next SQL i want to create automatically an insert statement
>(using q2:TIB_Query)
>
>insert into tbl(id,field1,field2,field3) values(:id,:field1,:field2,:field3)
>
>
>now i want to send each value from the first query
>
>for i:=0 to q1.fieldcount-1 do q2.params[i].value:=q1.fields[i].value;
>
>and execute this.
>
>
>
>When i was using ibx, it was no problem, when when i was
>using ibo, it gave me a arithmeitc truncation, ..... error, but i donĀ“t
>know, on which field.
>
>ibx version runs fine with all datatypes (also blob and other).
>
>
>any idea ?

Just ideas to consider - there's not enough information here to pinpoint
the exact problem.

The pertinent difference between IBX and native IBO here is that IBX will
reference a TField descendant, whereas IBO doesn't use persistent field
objects at all. You are getting the potential for run-time casting errors
because your code is using the Value method of the params[] and fields[]
objects of two different dataset objects. Value delivers variants, not
typed values; and by separating the first dataset from the second, the
second dataset has nothing to refer to when it needs to typecast the values.

As a guess, it's possible that you have an integer overflow here - perhaps
the second dataset is trying to push a 64-bit integer into a parameter
which it thinks is 32-bit...but it might well be a string overflow if you
are using Firebird 1 with large varchars...or a miscasting of a numeric or
integer to a float or double.

If possible, you should keep the Insert operation inside the context of the
first dataset and use its InsertSQL property to perform your
insert. Passing parameters from one dataset to another in order to perform
a DML operation on the same row is not very IBO-like. Is there any special
reason why you need a scrollable dataset to perform a DML query?


regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com