Subject Re: [IBO] two ParamEdit & SQL search
Author Helen Borrie
At 10:09 PM 5/11/2003 +0100, you wrote:
>Actually, I have read, that it's advised to use starting with instead of
>like (in isql) - can't say why, but there must be some messages in groups
>archive
>I was wondering, why 'starting with :ParamName' & paramedit isn't working
>as supposed

Agreed - the Firebird optimizer converts LIKE 'aString%' to STARTING WITH
'aString' anyway. The rule with LIKE is to avoid it, because it can't use
an index. But LIKE 'aString%' does use the index, because of the
internal conversion.

Your monitor output is confused because it is the first output since the
connection. All that RDB$ stuff is IBO pulling the metadata at connection.

Don't expect parameters to work with an unprepared statement. The sequence
should be

connect to database
....
....
start transaction
prepare statement
while prepared, iterate:
apply parameters
execute statement

In the prepare phase, null parameters are passed. This is what you are
seeing (eventually, after all the noise). Prepare is actually a "null
query": it validates the statement and passes the metadata image back to
the transaction. You shouldn't force the query to be prepared every time
it is executed.

Start things up in the right order, you will get this happening:

connect to database
start transaction (IBO does this)
query and cache metadata (IBO does this)
commit transaction (IBO does this)
<ready>

If you want to start with a searching interface, don't call Open on your
datasets.

Helen