473,804 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Delphi + Stored Procedure + Locks

John Hopfield wrote:
Maybe the transaction is already active?
The CALL of my Stored Procedure should terminate with a COMMIT? (i
never put "COMMIT" at end of my Stored Procedure)
If you were Pinocchio I'd say: "Listen to the grasshopper".
Locks have be held until the transaction commits.
Ideally your application should do this. But you add the COMMIT in your
procedure as well if it encapsulates a complete transaction.
In addition (not as a substitute) you also want to look at setting
DB2_SKIP_INSERT ED. Generally a good feature.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 30 '08 #1
7 3469
On 30 Giu, 13:47, Serge Rielau <srie...@ca.ibm .comwrote:
If you were Pinocchio I'd say: "Listen to the grasshopper".
:) (i live 100Km from Collodi :) )
Locks have be held until the transaction commits.
Ideally your application should do this. But you add the COMMIT in your
procedure as well if it encapsulates a complete transaction.
I have tried to add a "COMMIT" at the end of my Stored Procedure.
But nothing is changed.
In addition (not as a substitute) you also want to look at setting
DB2_SKIP_INSERT ED. Generally a good feature.
i will search the documentation of DB2_SKIP_INSERT ED..

JH
Jun 30 '08 #2
On 30 Giu, 15:14, John Hopfield <Hopfi...@freem ail.itwrote:
I have tried to add a "COMMIT" at the end of my Stored Procedure.
But nothing is changed.
Must i disconnect from DB2 and re-connect every-time?
(or close and open SQL querys ?)
JH
Jul 1 '08 #3
John Hopfield wrote:
On 30 Giu, 15:14, John Hopfield <Hopfi...@freem ail.itwrote:
>I have tried to add a "COMMIT" at the end of my Stored Procedure.
But nothing is changed.

Must i disconnect from DB2 and re-connect every-time?
(or close and open SQL querys ?)
JH
You definitely do not need to disconnect/reconnect. That would be really
bad for performance.

I don't know what close and open queries mean in your context....

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jul 2 '08 #4
John Hopfield wrote:
On 30 Giu, 13:47, Serge Rielau <srie...@ca.ibm .comwrote:
If you were Pinocchio I'd say: "Listen to the grasshopper".

:) (i live 100Km from Collodi :) )
Locks have be held until the transaction commits.
Ideally your application should do this. But you add the COMMIT in
your procedure as well if it encapsulates a complete transaction.

I have tried to add a "COMMIT" at the end of my Stored Procedure.
But nothing is changed.
You don't need a COMMIT in the stored proc definition - you need to
commit the transaction in your client's code.

My Delphi knowledge is rather rusty (v6), but you should find a Commit
method on the connection object (depending on the connection
architecture you're using ... I think the ADO components used something
different like EndTran, but all the rest used methods named Commit and
Rollback). Anyway - that's what you'll need to call to commit the
transaction.
Cheers,

Dave.
Jul 3 '08 #5
On 3 Lug, 03:19, "Dave Hughes" <d...@waveform. plus.comwrote:
You don't need a COMMIT in thestoredproc definition - you need to
commit the transaction in your client's code.

My Delphi knowledge is rather rusty (v6), but you should find a Commit
method on the connection object (depending on the connection
architecture you're using ... I think the ADO components used something
different like EndTran, but all the rest used methods named Commit and
Rollback). Anyway - that's what you'll need to call to commit the
transaction.

Cheers,

Dave.
Thank you Dave.
But when i call TDataBase.Commi t method it say that there is not an
active transaction.
So i think that is not a delphi problem.

Yesterday i found this...
In my Stored Procedure there are some "select into".
When i put the "WITH UR" clause at the end of these "select"
the lock on my table disappears...so the problem is resolved...

(no COMMIT at the end of my SP)

But there is another problem...

I don't have a good knowledge of transactions and isolation
levels...but...
i think that a select "WITH UR" it's a risk...because maybe its
possible
to retrieve "dirty" data not committed by another client...
and i don't want so...

JH
Jul 3 '08 #6
John Hopfield wrote:
On 3 Lug, 03:19, "Dave Hughes" <d...@waveform. plus.comwrote:
You don't need a COMMIT in thestoredproc definition - you need to
commit the transaction in your client's code.

My Delphi knowledge is rather rusty (v6), but you should find a
Commit method on the connection object (depending on the connection
architecture you're using ... I think the ADO components used
something different like EndTran, but all the rest used methods
named Commit and Rollback). Anyway - that's what you'll need to
call to commit the transaction.

Cheers,

Dave.

Thank you Dave.
But when i call TDataBase.Commi t method it say that there is not an
active transaction.
So i think that is not a delphi problem.
Ah, you'll need to "start" the transaction with the StartTransactio n
method first. In the case of DB2 this is essentially a no-op (you're
always "in a transaction" if you're connected to a DB2 database), but
the BDE connection architecture needs it anyway.

So, the code for calling your SP should look something like the
following (assuming no silly errors:

{ DB is a connected TDatabase component, SP is a TStoredProc component
with the various properties (StoredProcName , Params, etc.) already
filled out }

DB.StartTransac tion;
try
SP.ExecProc;
DB.Commit;
except
on E: Exception do begin
// Something's gone horribly wrong - rollback the
// transaction and report the error
DB.Rollback;
MessageDlg(E.Me ssage, mtError, [mbOk], 0);
end;
end;
Yesterday i found this...
In my Stored Procedure there are some "select into".
When i put the "WITH UR" clause at the end of these "select"
the lock on my table disappears...so the problem is resolved...

(no COMMIT at the end of my SP)

But there is another problem...

I don't have a good knowledge of transactions and isolation
levels...but...
i think that a select "WITH UR" it's a risk...because maybe its
possible
to retrieve "dirty" data not committed by another client...
and i don't want so...
That's correct. WITH UR is "with uncommitted read"; in other words it
permits the query to read changed rows which haven't yet been committed
by other transactions. If you want to ensure that a particular
transaction isolation level is used (other than whatever the client
stipulates), I'd suggest WITH CS.

Speaking of which, what's the TransIsolation property of your TDatabase
component set to? If its set to tiRepeatableRea d, then that's your
problem - set it to tiReadCommitted (the default) instead (I /think/
tiReadCommitted translates to CS in the case of DB2 - I'm not sure
though - I'll try and do a bit of digging later).

Anyway - the main problem here is long running transactions. If you're
not explicitly committing the transaction, then its remaining active
(and potentially holding locks) for as long as you're connected to the
database. Using something like the code above to ensure that the stored
proc execution is committed (or rolled back) ASAP should fix any
contention issues you're having. Still, check the TransIsolation
property too.
Cheers,

Dave.
Jul 3 '08 #7
On 3 Lug, 21:12, "Dave Hughes" <d...@waveform. plus.comwrote:
Hmm - rather than answer that directly I'll try and give an overview on
how various method calls in Delphi translate into actions in DB2 -
hopefully that should explain the situation above. My apologies if any
of the following appears patronizing - I've assumed very little
knowledge purely in the interests of completeness:
Thank you Dave for your time.

JH
Jul 4 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9013
by: A.V.C. | last post by:
Hello, Can we lock stored procedure until its execution is complete ? I dont want 2 clients to simultenously execute the stored procedure in Sql Server 2000. My front end is ASP.net 1.0 Thanks in advance. waiting for the reply.
5
2608
by: rhungund | last post by:
Hi All. My question is this. I have a complex stored procedure in SQL Server which works fine when I run it in Query Analyzer. However, when I call it within my ASP script, it returns nothing, and sometimes locks up. If I change my script to call other existing stored procedures it works fine. It's just with this particular stored proc. I have tried various DB calls in ASP, such as opening the recordset through an ADO connection and...
7
9230
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into a table (c) re-queries another table using a subquery which references the inserted table (correlated or not)
1
2780
by: imarchenko | last post by:
Hello! I am trying to investigate strange problem with particular stored procedure. It runs OK for several days and suddenly we start getting and lot of locks. The reason being lock placed on this procedure. As a result, we have 40-50 other connections waiting, then next connection using this procedure has lock etc. Client is fully qualifying
0
909
by: Howard Carr | last post by:
I have a stored procedure that I want to add to my data set. I've followed the procedures to do this - open server connection, go to stored procedure tab and drag procedure onto design form. The procedure is then shown, but no column information is retrieved. For regular stored procedures that just have a select to return a collection of rows, it ok. But my procedure sets up and executes an openquery to a linked server. My previous...
1
2554
by: Crazy Cat | last post by:
I'm calling several SQL Server 2005 stored procedures from Visual Basic 2005. I've got one stored procedure that locks up at the same point everytime, but if I copy the stored procedure from the SQL Profiler trace and paste it into SQL Server Management Studio it runs fine -- I even tried setting the timeout in Visual Studio to unlimited to see if the procedure would ever complete and it doesn't. What the hell is going on? Here is the...
2
1827
by: rokslide | last post by:
Hi all, I have a web application which (until a few weeks ago) was running fine. Now, periodically, a stored procedure will stop responding and timeout when called via the web application. The stored procedure varies (eg. so far this problem has happened twice and it has been a different stored proc each time) and if the stored procedure is executed in the query analyzer it executes without a problem and within a second. Looking at...
3
3174
by: Racerx | last post by:
Hi All: I use db2 v8 fp 14 on Aix. I am facing problems with a stored procedure that is causing a lot of locks and also goes in the lock wait state ending up hanging the application. Tried using the UR isolation mode but it did not help. Can some one please suggest me how to debug this problem and any
5
6464
by: william.david.anderson | last post by:
Hi there, I have a newbie question regarding stored procedures and locking. I'm trying to use a stored procedure to perform a 'select for update' and return a cursor. Below is a stripped down version of the procedure: CREATE PROCEDURE SELBTFLFORUPDATE() LANGUAGE SQL
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.