Subject Re: [IBO] TIBOQuery & n-tier updates
Author Helen Borrie
At 07:43 PM 13/06/2004 +0000, you wrote:
>Is it possible to link TIBOQuery with a TDataSetProvider where
>Delete/Edit and Insert sql's are stored procedures?
>I tried a simple sp for deletes with the primary key as input
>parameter, but its value is not set (automatically).
>Do I need to Execute several TD_SQL components from the Provider's
>BeforeUpdateRecord event handler?

No, not at all. The IBODataset does that itself and it uses
ExecuteImmediate. In the normal course of events, the IBODataset creates
the UpdateSQL statements itself, using the KeyLinks to build the WHERE
clause and populate the XSQLDAs.

You only need to configure the property explicitly where you have to call
custom SQL to perform the operation - as is perhaps your situation here -
it's necessary for joined sets that need more than one table updated, for
example. If you only want one table from a joined set to be updated, you
can use the KeyRelation property to tell IBO which table, and you won't
need custom SQL unless you have something special to do.

Just put your parameterised UpdateSQL in the relevant property (EditSQL,
InsertSQL, DeleteSQL) of the provider. Make sure you have the correct
KeyLinks set. You'll save some code if the parameter names match the
KeyLinks names. If the names are mismatched, or you want to intervene in
some special way, e.g. to do some kind of validation, you'll have to assign
the parameter values yourself in the Before event.

>In that case I'm interested to learn
>how to implement the AParam parameter of type PXSQLDA of the
>ExecuteImmediate method (recommended by Jason in message 25390).

This is necessary only if you have to call ExecuteImmediate in your own
code. If you have a dog, you don't need to bark yourself...

The API Guide explains usage and data and where the XSQLDA structures fit
into the big picture. Probably the only way you're going to get hold of
this is to track through the code to see the declarations and how the code
instantiates, populates and uses an XSQLDA record. Start in IB_Header.pas
and work through IB_Components.pas.

If you decide to walk this rarefied path, a Howto article would be warmly
accepted. :-)