Subject RE: [IBO] TIB_dSQL Success Test
Author IBO Support List
Jack,
 
I expect you to make some basic effort here, ok?
Do a Google search on "Firebird SQL INSERT RETURNING".
Put a returning clause on your INSERT statement in your SQL.
Use the FieldByName() after you ExecSQL your TIB_DSQL.
 
Jason
 

From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf Of John W. (Jack) Cane
Sent: Friday, September 20, 2013 8:01 AM
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] TIB_dSQL Success Test

theQuery.Fields[0] generates an access violation. Something wrong with my syntax. Do you have any sample code?

Best,
jwc
from iMac

On Sep 20, 2013, at 9:44 AM, IBO Support List <supportlist@...> wrote:

 

If you are using a recent version of Firebird you can add a RETURNING clause to your INSERT statement. The columns included in it will show up in the Fields array where you can do a FieldByName( 'MYCOL' ).AsInteger...
 
If a trigger assigns a generator value, it will come back to you there.
 
Jason
 


From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf Of John W. (Jack) Cane
Sent: Friday, September 20, 2013 7:37 AM
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] TIB_dSQL Success Test

Is it possible to retrieve the primary key value of a single row inserted?

Best,
jwc
from iMac

On Sep 20, 2013, at 12:30 AM, IBO Support List <supportlist@...> wrote:

 

You can check the RowsAffected property.
 
Jason
 


From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf Of John W. (Jack) Cane
Sent: Thursday, September 19, 2013 10:03 PM
To: IBObjects Support
Subject: [IBO] TIB_dSQL Success Test

Please advise the best, the correct test to confirm success of an insert query using variable dSql of type tiB_dSQL.

Inherited, legacy code contains a test for the value of dSql.Fields[0].AsInteger. That fails with an access violation.

If that is the best test, would you please give me the required statement to prepare that query. I tried appending the clause, 'Returning ' + pkFieldName, but the error remains.

Would prefer to make the code general, with the given condition that Fields[0] is always the primary key field of my tables.

Best,
jwc
from iMac