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.

execute vs executeQuery bug?

2 posts in JConnect version 3.0 Last posting was on 1998-09-30 10:56:09.0Z
Carl P. Miller Posted on 1998-09-29 22:20:30.0Z
Message-ID: <36115D2E.E2E5DCA9@aetna.com>
Date: Tue, 29 Sep 1998 18:20:30 -0400
From: "Carl P. Miller" <millerc5@aetna.com>
X-Mailer: Mozilla 4.01 [en] (WinNT; U)
MIME-Version: 1.0
Subject: execute vs executeQuery bug?
X-Priority: 3 (Normal)
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jconnect30
Lines: 22
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jconnect30:398
Article PK: 256616

We have a simple, valid stored procedure which goes something like this:

select @temp = somesimplequery w/simple where clause

if @@rowcount > 0
select 1
else
select 0

The problem we run into is we use Statement.execute() and we get no
result set upon
calling getResults(). If we use Statement.executeQuery(), everything
works fine and we get
a result set. Unfortunately, the code issuing the execute? is generic
and won't know to do
one vs the other, as it also executes SP's that do updates. Using
executeQuery for these
types of SP's caused an exception.

The question boils down to, is there a problem with the temporary data
being returned such
that execute() doesn't work but executeQuery() does?

The environment we're running is ASE 11.? (not 11.5, I think it's 11.3)
with JConnect 4.0.

Carl Miller


Lance Andersen Posted on 1998-09-30 10:56:09.0Z
Message-ID: <36120E49.98010E71@sybase.com>
Date: Wed, 30 Sep 1998 06:56:09 -0400
From: Lance Andersen <lancea@sybase.com>
X-Mailer: Mozilla 4.05 [en] (X11; I; SunOS 5.5.1 sun4m)
MIME-Version: 1.0
Subject: Re: execute vs executeQuery bug?
References: <36115D2E.E2E5DCA9@aetna.com>
Content-Type: multipart/mixed; boundary="------------4DBE4E0D5C8EB4F3D26A2057"
Newsgroups: sybase.public.jconnect30
Lines: 73
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jconnect30:396
Article PK: 254631

There is not a problem with execute, but there is most likely a logic
problem in your example.


Please see the samples $JDBC_HOME/sample/IsqlApp.java or Execute.java.


execute() returns a true or false stating whether the 1st thing on the
wire is a ResultSet. If it is not a ResultSet(i.e. execute() returns
false), you need to call getUpdateCount() and if that is not -1 call
getMoreResults().

executeQuery() is only meant to be used for simple selects, not
batches. if your queries are not known, you need to use execute().


-lance

Team Sybase

Carl P. Miller wrote:
>
> We have a simple, valid stored procedure which goes something like this:
>
> select @temp = somesimplequery w/simple where clause
>
> if @@rowcount > 0
> select 1
> else
> select 0
>
> The problem we run into is we use Statement.execute() and we get no
> result set upon
> calling getResults(). If we use Statement.executeQuery(), everything
> works fine and we get
> a result set. Unfortunately, the code issuing the execute? is generic
> and won't know to do
> one vs the other, as it also executes SP's that do updates. Using
> executeQuery for these
> types of SP's caused an exception.
>
> The question boils down to, is there a problem with the temporary data
> being returned such
> that execute() doesn't work but executeQuery() does?
>
> The environment we're running is ASE 11.? (not 11.5, I think it's 11.3)
> with JConnect 4.0.
>
> Carl Miller

--
===============================================================================
Lance J. Andersen Email: lancea@sybase.com
Sybase Product Support Engineering Phone:(781) 564-6336
77 South Bedford Street Fax: (781) 564-6148
Burlington, MA 01803

The Dark Knight Returns!!! Let's Go Penguins!!!
===============================================================================


Download VCard vcard.vcf