Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Query being checked

5 posts in Delphi Last posting was on 2012-01-05 12:54:02.0Z
Tim Murfitt Posted on 2012-01-04 18:13:56.0Z
Reply-To: "Tim Murfitt" <tim@tmurfitt.co.uk>
From: "Tim Murfitt" <tim@tmurfitt.co.uk>
Newsgroups: Advantage.Delphi
Subject: Query being checked
Date: Wed, 4 Jan 2012 18:13:56 -0000
Lines: 2
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 15.4.3508.1109
X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3508.1109
NNTP-Posting-Host: 82.70.207.190
Message-ID: <4f0496c9@solutions.advantagedatabase.com>
X-Trace: 4 Jan 2012 10:13:29 -0700, 82.70.207.190
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25600
Article PK: 1109179

Hi

I have just upgraded from Delphi 2007 to Delphi XE2 and have found that a
project that previously worked is now having problems. I do not know if the
behaviour is as expected in XE2 or is wrong.

When the form is created the first thing that i do is check using TAdsTable
if a number of tables exist. If they do not then i execute various
TAdsQueries to create the tables. The problem is that is as soon as the
form is created and before my routine has a chance to check for the tables
the Queries are automatically "run" and report an error (Table already
exists). By adding a Try, Catch All, End Try to the queries the problem is
resolved.

My questions are: Are the queries actually being executed or are they just
being checked? Is this as expected in XE2 or is there something wrong? If
it is as expected is there anyway of stopping it?

Regards

Tim Murfitt


Alan Posted on 2012-01-04 18:45:20.0Z
From: "Alan" <observa_spam_sucks@xtra.co.nz>
Newsgroups: Advantage.Delphi
References: <4f0496c9@solutions.advantagedatabase.com>
Subject: Re: Query being checked
Date: Thu, 5 Jan 2012 07:45:20 +1300
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 125.239.62.85
Message-ID: <4f049e17$1@solutions.advantagedatabase.com>
X-Trace: 4 Jan 2012 10:44:39 -0700, 125.239.62.85
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25601
Article PK: 1109181


"Tim Murfitt" <tim@tmurfitt.co.uk> wrote in message
news:4f0496c9@solutions.advantagedatabase.com...
> Hi
>
> I have just upgraded from Delphi 2007 to Delphi XE2 and have found that a
> project that previously worked is now having problems. I do not know if
> the behaviour is as expected in XE2 or is wrong.
>
> When the form is created the first thing that i do is check using
> TAdsTable if a number of tables exist. If they do not then i execute
> various TAdsQueries to create the tables. The problem is that is as soon
> as the form is created and before my routine has a chance to check for the
> tables the Queries are automatically "run" and report an error (Table
> already exists). By adding a Try, Catch All, End Try to the queries the
> problem is resolved.
>
> My questions are: Are the queries actually being executed or are they
> just being checked? Is this as expected in XE2 or is there something
> wrong? If it is as expected is there anyway of stopping it?
>
> Regards
>
> Tim Murfitt

Tim

I'm using D2009 and find that queries don't execute properly if run in the
Form.OnCreate method. I need to run them in the OnActivate or onShow
methods. Then they execute properly. Perhaps the same behaviour applies in
XE2?

Alan


Tim Murfitt Posted on 2012-01-04 19:14:48.0Z
Reply-To: "Tim Murfitt" <tim@tmurfitt.co.uk>
From: "Tim Murfitt" <tim@tmurfitt.co.uk>
Newsgroups: Advantage.Delphi
References: <4f0496c9@solutions.advantagedatabase.com> <4f049e17$1@solutions.advantagedatabase.com>
In-Reply-To: <4f049e17$1@solutions.advantagedatabase.com>
Subject: Re: Query being checked
Date: Wed, 4 Jan 2012 19:14:48 -0000
Lines: 2
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 15.4.3508.1109
X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3508.1109
NNTP-Posting-Host: 82.70.207.190
Message-ID: <4f04a50d$1@solutions.advantagedatabase.com>
X-Trace: 4 Jan 2012 11:14:21 -0700, 82.70.207.190
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25602
Article PK: 1109180

Alan

Thanks for that tip. I dont think it is the answer in this case but it did
lead me to finding out what the problem is. There are in fact two issues.
The first is that the Delphi debugger does not seem to be working correctly
as the code does not break as directed. I therefore did not realise that
the problem is that the TAdsTable.exists is incorrectly reporting false and
therefore my query to create the tables is executing when i did not expect
it. If anyone has any ideas on either of these two points that would be
great but otherwise the issue with the Query unexpectedly firing is
resolved.

Regards

Tim



"Alan" wrote in message news:4f049e17$1@solutions.advantagedatabase.com...

"Tim Murfitt" <tim@tmurfitt.co.uk> wrote in message
news:4f0496c9@solutions.advantagedatabase.com...
> Hi
>
> I have just upgraded from Delphi 2007 to Delphi XE2 and have found that a
> project that previously worked is now having problems. I do not know if
> the behaviour is as expected in XE2 or is wrong.
>
> When the form is created the first thing that i do is check using
> TAdsTable if a number of tables exist. If they do not then i execute
> various TAdsQueries to create the tables. The problem is that is as soon
> as the form is created and before my routine has a chance to check for the
> tables the Queries are automatically "run" and report an error (Table
> already exists). By adding a Try, Catch All, End Try to the queries the
> problem is resolved.
>
> My questions are: Are the queries actually being executed or are they
> just being checked? Is this as expected in XE2 or is there something
> wrong? If it is as expected is there anyway of stopping it?
>
> Regards
>
> Tim Murfitt

Tim

I'm using D2009 and find that queries don't execute properly if run in the
Form.OnCreate method. I need to run them in the OnActivate or onShow
methods. Then they execute properly. Perhaps the same behaviour applies in
XE2?

Alan


Joachim Duerr (ADS) Posted on 2012-01-05 09:45:23.0Z
From: "Joachim Duerr (ADS)" <jojo.duerr@gmx.de>
Subject: Re: Query being checked
Newsgroups: Advantage.Delphi
References: <4f0496c9@solutions.advantagedatabase.com> <4f049e17$1@solutions.advantagedatabase.com> <4f04a50d$1@solutions.advantagedatabase.com>
Date: Thu, 5 Jan 2012 10:45:23 +0100
User-Agent: XanaNews/1.19.1.269
X-Face: u2p+</,mb|Ah!x!/qxX5q0t:O~.<1&JzwNHYhSqcviY{~&|iDc"U.Je1A.ZeHR`d;;y#R
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 10.29.66.130
Message-ID: <4f0570cb@solutions.advantagedatabase.com>
X-Trace: 5 Jan 2012 01:43:39 -0700, 10.29.66.130
Lines: 39
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25603
Article PK: 1109183


Tim Murfitt wrote:

>Thanks for that tip. I dont think it is the answer in this case but
>it did lead me to finding out what the problem is. There are in fact
>two issues. The first is that the Delphi debugger does not seem to be
>working correctly as the code does not break as directed. I
>therefore did not realise that the problem is that the
>TAdsTable.exists is incorrectly reporting false and therefore my
>query to create the tables is executing when i did not expect it. If
>anyone has any ideas on either of these two points that would be
>great but otherwise the issue with the Query unexpectedly firing is
>resolved.

you shouldn't use TAdsTable.Exists method. It requires direct file
access.
Do you use data dictionaries? If so, use SQL only:

if not exists (select * from system.tables where name like 'mytable'
then
create table mytable (....);
endif;


You could do something similar with free tables, but this will generate
entries in the ads_err:

declare @s string;
try
@s=(select top 1 id from mytable);
catch all
if __errcode=7041 then
create table mytable(i autoinc, c char(20));
endif;
end try;

--
Joachim Duerr, Advantage Presales
*** NEW *** Advantage Pocket Guide released *** NEW ***
http://pocketguide.jd-engineering.de


Tim Murfitt Posted on 2012-01-05 12:54:02.0Z
Reply-To: "Tim Murfitt" <tim@tmurfitt.co.uk>
From: "Tim Murfitt" <tim@tmurfitt.co.uk>
Newsgroups: Advantage.Delphi
References: <4f0496c9@solutions.advantagedatabase.com> <4f049e17$1@solutions.advantagedatabase.com> <4f04a50d$1@solutions.advantagedatabase.com> <4f0570cb@solutions.advantagedatabase.com>
In-Reply-To: <4f0570cb@solutions.advantagedatabase.com>
Subject: Re: Query being checked
Date: Thu, 5 Jan 2012 12:54:02 -0000
Lines: 2
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 15.4.3508.1109
X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3508.1109
NNTP-Posting-Host: 82.70.207.190
Message-ID: <4f059d4c@solutions.advantagedatabase.com>
X-Trace: 5 Jan 2012 04:53:32 -0700, 82.70.207.190
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25605
Article PK: 1109186

Joachim

Thanks for the response. I will use sql to check. Is there any occasion
when it is ok to use TAdsTable.Exists method or is it something to always
avoid. If so are there any other similar methods to avoid.

Regards

Tim


"Joachim Duerr (ADS)" wrote in message
news:4f0570cb@solutions.advantagedatabase.com...

Tim Murfitt wrote:

>Thanks for that tip. I dont think it is the answer in this case but
>it did lead me to finding out what the problem is. There are in fact
>two issues. The first is that the Delphi debugger does not seem to be
>working correctly as the code does not break as directed. I
>therefore did not realise that the problem is that the
>TAdsTable.exists is incorrectly reporting false and therefore my
>query to create the tables is executing when i did not expect it. If
>anyone has any ideas on either of these two points that would be
>great but otherwise the issue with the Query unexpectedly firing is
>resolved.

you shouldn't use TAdsTable.Exists method. It requires direct file
access.
Do you use data dictionaries? If so, use SQL only:

if not exists (select * from system.tables where name like 'mytable'
then
create table mytable (....);
endif;


You could do something similar with free tables, but this will generate
entries in the ads_err:

declare @s string;
try
@s=(select top 1 id from mytable);
catch all
if __errcode=7041 then
create table mytable(i autoinc, c char(20));
endif;
end try;

--
Joachim Duerr, Advantage Presales
*** NEW *** Advantage Pocket Guide released *** NEW ***
http://pocketguide.jd-engineering.de