Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread TDBISAMQuery SQLStatementType suggestion
Tue, Feb 28 2006 3:30 AMPermanent Link

"Robert Cram"
Hi Tim,

If you're using a script with multiple statements, the SQLStatementType
of a DBISAMQuery returns the statementtype based on the first SQL
statement.

This poses a problem when you want to use the code below and you have a
script consisting of a select and an update statement:

if DBISAMQuery.SQLStatementType = stSelect
 then DBISAMQuery.Open
 else DBISAMQuery.ExecSQL

Any change of having the SQLStatementType return the statement type of
the LAST statement in a script?

Regards,
Robert.
Tue, Feb 28 2006 3:44 AMPermanent Link

"Ralf Mimoun"
Robert Cram wrote:
> Hi Tim,
>
> If you're using a script with multiple statements, the
> SQLStatementType of a DBISAMQuery returns the statementtype based on
> the first SQL statement.
>
> This poses a problem when you want to use the code below and you have
> a script consisting of a select and an update statement:
>
> if DBISAMQuery.SQLStatementType = stSelect
>  then DBISAMQuery.Open
>  else DBISAMQuery.ExecSQL

Simply call ExecSQL all the time. It will open the resulting dataset if the
last statement in the script is a SELECT.

Ralf
Tue, Feb 28 2006 3:58 AMPermanent Link

"Robert Cram"
Hi Ralf,

You're right. I know this from the DBSYS utility, but never thought of
implementing it that way in code.

But is there a way to tell from the resulting query if it is an empty
dataset (in which case I want to return the dataset) or "the result" of
an update statement (in which case I want to return nil)?

Regards,
Robert



Ralf Mimoun wrote:

> Robert Cram wrote:
> > Hi Tim,
> >
> > If you're using a script with multiple statements, the
> > SQLStatementType of a DBISAMQuery returns the statementtype based on
> > the first SQL statement.
> >
> > This poses a problem when you want to use the code below and you
> > have a script consisting of a select and an update statement:
> >
> > if DBISAMQuery.SQLStatementType = stSelect
> > then DBISAMQuery.Open
> > else DBISAMQuery.ExecSQL
>
> Simply call ExecSQL all the time. It will open the resulting dataset
> if the last statement in the script is a SELECT.
>
> Ralf



--
Tue, Feb 28 2006 4:02 AMPermanent Link

"Ralf Mimoun"
Robert Cram wrote:
> Hi Ralf,
>
> You're right. I know this from the DBSYS utility, but never thought of
> implementing it that way in code.
>
> But is there a way to tell from the resulting query if it is an empty
> dataset (in which case I want to return the dataset) or "the result"
> of an update statement (in which case I want to return nil)?

"if Query.Active = True..." should do the job.

Ralf
Tue, Feb 28 2006 4:13 AMPermanent Link

"Robert Cram"
Everything in life should be so simple Wink

Using ExecSQL instead of Open works like a charm.

Thanks Ralf!


Ralf Mimoun wrote:

>
> "if Query.Active = True..." should do the job.
>
> Ralf



--
Tue, Feb 28 2006 8:56 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Robert,

<< Any change of having the SQLStatementType return the statement type of
the LAST statement in a script? >>

Got in here late, but you can use a TDBISAMQuery.BeforeExecute event handler
to examine the SQLStatementType for the current SQL statement being executed
or store it for later examination.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image