Subject Re: [IBO] macro-field and parameter combined
Author Jason Wharton
> I was playing with some macro stuff and wondered if something like this
> would be possible:
>
> select <<Field>> from <<Table>>
> where <<Search>> = :searchparam
>
> Must this query be prepared *before* the parameter is set?
>
> In the MacroSubst-Event the text-blocks are correctly set.
>
> What is the processing order?
> First substitute the parameters, or vice versa, or completely mixed?

You put in the events that make the appropriate substitution and then use it
as normal. It is not supported to be an any official firing order that you
should exploit in some way.

In general, you can expect the OnMacroubstitute event to be fired during the
time the statement is being prepared and or re-prepared depending on what
you are doing with the dataset. It is also possible for it to get fired off
during things like the Locate() operation since it is internally working
with pieces of your SQL, but in theory, it should only be working off of the
raw SQL that was sent to the server to be prepared at that point.

I don't recommend you have a macro with the whole significant contents of
your query missing. You just as well directly alter the SQL statement. My
implementation of macros may not hold up under heavy operations when there
is so little meaningful information in the original SQL statement.

One example would be you may substitute in use of a JOIN. It may be
important for IBO to know it is a JOINed dataset but it may not be able to
tell at a time it might need to know. Not sure this is a case, but I want it
to be clear macros are potentially limiting in what you are trying to
accomplish. I consider them most useful in the TIB_Script component and
other straight forward batch-like operations, not an interactive user
interface. I have much better mechanisms than macros for the interactive
stuff.

PS. This too should be a FAQ item.

HTH,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com