ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Multiple SQL statements in a single line of ESQL

Post new topic  Reply to topic
 Multiple SQL statements in a single line of ESQL « View previous topic :: View next topic » 
Author Message
shalabh1976
PostPosted: Wed Sep 17, 2008 3:44 am    Post subject: Multiple SQL statements in a single line of ESQL Reply with quote

Partisan

Joined: 18 Jul 2002
Posts: 381
Location: Gurgaon, India

Hi,
I have 10-15 SQL statements that are independant of each other. However if I were to run them from ESQL this would involve 10-15 round trips to the database. Is there any way I can combine these statements and fire a single statement so that there is only 1 round trip?

Thanks and Regards,
Shalabh
_________________
Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
mqjeff
PostPosted: Wed Sep 17, 2008 3:50 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You can do nested selects.
Back to top
View user's profile Send private message
shalabh1976
PostPosted: Thu Sep 18, 2008 1:21 am    Post subject: Reply with quote

Partisan

Joined: 18 Jul 2002
Posts: 381
Location: Gurgaon, India

We have many DELETES and I have no idea how to nest them.
I did some search on the net and I found the command SQLExecDirect for SQL Server 2005(which is the underlying database). However I have no idea as to use it from ESQL.
_________________
Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
fjb_saper
PostPosted: Thu Sep 18, 2008 2:01 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Think stored procedure.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
elvis_gn
PostPosted: Thu Sep 18, 2008 7:57 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi all,
mqjeff wrote:
You can do nested selects.

Maybe not possible since
shalabh1976 wrote:
I have 10-15 SQL statements that are independant of each other


But stored procedure should be the first step as fjp_saper suggests...Make one call, and let the procedure to all the deletes...

Regards.
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Thu Sep 18, 2008 8:39 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The independance of the statements does not interfere with the ability to select the total set of all results from each statement.

I am not sure if the fact that the statements are DELETEs will interfere with the ability to select the total set of all results from each statement.

A stored procedure is good. A passthru full of ";" may be sufficient.
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Thu Sep 18, 2008 9:55 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi mqjeff,

There is a big difference in what "can be done" and what "should be done"...

In this example...

1. You CAN put all the SQL statements into one PASSTHRU and delete the database records.

2. You CAN nest (or better join the queries) as something common in the input must be the parameter for all deletion.

But you should not because...

1. Who does the database administator question if every developer of every possible team is firing deletes on his database...it becomes impossible to track and maintain data consistency, that is why stored procedures...doing selects or even inserts/updates is ok, but deleting data is a little risky when done all over the place.
2. 15 selects(forget even deletes) in one passthru What kind of error handling will you provide for such a statement, just throw it as a heap to the MQ admin ? Tracing errors is going to be tougher.

3. What performance do you gurantee ? 15 calls is a little too much even if called from 1 passthru...all 15 in 1 passthru does not mean it takes the time of 1 query, does it ? A stored procedure will atleast do better...

4. Long running SELECT queries sometimes make the flow look inconsitent and the JVM to crash, then just imagine if the DELETE is waiting for other previous DELETES to be committed ? (ignoring that the database handles it to a good degree)...and then you have 15 of them too together...you could find the JVM to shoot and no response being returned from the database call...and as of v6.0, i have not heard of database call timeouts(not sure if its in v6.1)...

For these reasons, don't do something just coz it can be done that way.

Regards.
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Thu Sep 18, 2008 10:03 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Oh sure. I never said any of these were *good* ideas.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Multiple SQL statements in a single line of ESQL
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.