Subject RE: [IBO] Apparent bug in assigning a qry.fieldbyname to a parameter in DSQL
Author Jason Wharton
So glad you figured this out!
 
Thanks for letting me know.
 
Jason


From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Sunday, August 12, 2018 12:36 AM
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] Apparent bug in assigning a qry.fieldbyname to a parameter in DSQL

Hi, Jason:

I finally figured it out:

I was doing:

with qry do
begin
//set up qry and open...
with dsql do
begin
//set up dsql, prepare
   with qry do //this query was a singleton opened above the use of the dsql
  begin
  Parambyname('param').asString := FieldByName('fieldname').asString;
  end
end
end

Clearly, the code was seeing some ambiguity with ParamByName's owner.

When I removed the "with qry do" and explicitly referenced qry.fieldbyname(), everything worked fine.

Of course, it took hours to figure this out and now I have less hair.

Thank you,

Chuck


On 8/11/2018 7:08 PM, 'Jason Wharton' jason@... [IBObjects] wrote:
This sounds like something quite strange.
I'll probably need to see a sample app if you can reproduce it.
 
Let me know.
 
Jason Wharton


From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Saturday, August 11, 2018 12:19 PM
To: IBObjects Listserve
Subject: [IBO] Apparent bug in assigning a qry.fieldbyname to a parameter in DSQL

 

Hello:

I have a weird, frustrating apparent bug:

I am using a created IB_Cursor, "qry",  to select from a local database
a singleton. Then with a IB_DSQL I am updating a remote database table.

In the DSQL, I am using parameterized statements (e.g. FieldName and
:FieldName after VALUES).

After Prepare, I assign the values to the parameters, using
qry.fieldbyname('fieldname').asString.

ParambyName('FieldName').asString := qry.FieldByName('fieldname').asString;

On the above line I am getting the error, "Fieldname not found,
FieldName". This is coming from IB_Components.TIB_Row.ByName assertion,
calling GetByName(). I am unable to trace (not able to set break
points--during runtime the breakpoints disappear, F7 does not work) the
IBO code.

On checking both values for ParambyName('FieldName').asString and
qry.FieldByName('fieldname').asString during runtime, they are as
expected. In other words, the field, FieldName, does exist in the qry
dataset.

And the fieldname does exist in both tables.

Any ideas or suggestions on what is going on here?

Sometimes I have found problems resolve by changing from a IB_Cursor to
a IB_Query. That did not resolve this issue.

Thank you,

Chuck

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus