resultSet and Statements

resultSet and Statements

Post by Yaw » Thu, 28 Mar 2002 21:52:58



Hi,

I just like to check if there is a more efficient way of doing the
following.

Currently I need to execute two SQL statements; the second SQL statement
depends on the results of the first SQL statement.

To do this, I have used 'two' Statement objects and 'ResultSet' objects, as
otherwise the first ResultSet will be cleared when another SQL statement is
executed.

I'm wondering whether this is the correct thing to do in such a situation.
As I think it can get really out of hand if I have to execute say five or
six SQL statements and then having to create five or six 'Statement'
objects.

Any help or discussion on this is much appreciated.

Thanks in Advance.

Yaw.

 
 
 

resultSet and Statements

Post by Davide Bianch » Thu, 28 Mar 2002 22:06:35



Quote:> I just like to check if there is a more efficient way of doing the
> following.

> Currently I need to execute two SQL statements; the second SQL
> statement depends on the results of the first SQL statement.

Cant' you use a single SQL Select or a Stored Procedure to process
the data inside the database itself ? Otherwise, there isn't much
to do about it.

Davide

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

 
 
 

resultSet and Statements

Post by Mike Heber » Thu, 28 Mar 2002 22:09:55


This is dependent on what the SQL queries do.  It may be possible to do a
nested select or some type of join. If you post your table definitions and
the queries we may be better able to help you.

If it is not possible to create a better SQL query then what you are doing
is fine.

-Mike-


Quote:> Hi,

> I just like to check if there is a more efficient way of doing the
> following.

> Currently I need to execute two SQL statements; the second SQL statement
> depends on the results of the first SQL statement.

> To do this, I have used 'two' Statement objects and 'ResultSet' objects,
as
> otherwise the first ResultSet will be cleared when another SQL statement
is
> executed.

> I'm wondering whether this is the correct thing to do in such a situation.
> As I think it can get really out of hand if I have to execute say five or
> six SQL statements and then having to create five or six 'Statement'
> objects.

> Any help or discussion on this is much appreciated.

> Thanks in Advance.

> Yaw.

 
 
 

resultSet and Statements

Post by Yaw » Fri, 29 Mar 2002 22:38:33


Really it's fine?  I thought it would be bad programming practice.  :)

Anyways,
Thanks guys.

Yaw.


> This is dependent on what the SQL queries do.  It may be possible to do a
> nested select or some type of join. If you post your table definitions and
> the queries we may be better able to help you.

> If it is not possible to create a better SQL query then what you are doing
> is fine.

> -Mike-



> > Hi,

> > I just like to check if there is a more efficient way of doing the
> > following.

> > Currently I need to execute two SQL statements; the second SQL statement
> > depends on the results of the first SQL statement.

> > To do this, I have used 'two' Statement objects and 'ResultSet' objects,
> as
> > otherwise the first ResultSet will be cleared when another SQL statement
> is
> > executed.

> > I'm wondering whether this is the correct thing to do in such a
situation.
> > As I think it can get really out of hand if I have to execute say five
or
> > six SQL statements and then having to create five or six 'Statement'
> > objects.

> > Any help or discussion on this is much appreciated.

> > Thanks in Advance.

> > Yaw.

 
 
 

1. closing resultset (directly or through closing a statement)

Hi all,

I run into a stall when cancelling a large resultset.

I make the following steps:
(1) get conn.
(2) create stmt for 2.5 mil rec.
(3) read 1000 recs
(4) process
(5) cancel stmt
(6) close stmt
(7) close conn.

The problem is that it still takes about 100 secs to close the stmt.
I tried the cancelling the statement as was sigeested in another
posting.  Another possibility is that I can just close the connection.
 The requirement to close the statement (and therefore the resultset)
could be in the context of running many queries with the same
connection, in which case the need is obvious.  Any ideas?

I'm using jdbc on oracle 9i.

2. FREE SOFTWARE !

3. Java / Oracle Callable Statement with Null ResultSet

4. "Field not of expected type" error??

5. Can't close statement, resultset

6. PDOXWIN <-> ORACLE via ODAPI

7. Closing the connections, statements and resultsets

8. License Issue

9. ResultSet/Statement Q.

10. Size Limit for ResultSet/Statement Object

11. Size Limit for ResultSet/Statement objects

12. Multiple resultsets/statements on a connection?

13. Geting the resultset out of a PROCEDURE INTO A select statement