473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DB2 SQL Procedure Multi User Env.

Hi,

I have a small doubt in SQL Procedures in DB2.

It is the first time that I am using DB2 UDB, so please bear me.

Following, is a very small example to put across my doubt.

In following procedure we have a select query query which returns only one row, and after some processing I update the same row.

My question is if two different clients runs the same procedure with the same input parameter, Is it every possible that procedure may return the same serial number.

How actually procedures are handled in multi user environment?

Do I need to write sql with explicit locking? (eg WITH CS, RR or RS)

How actually the "FOR UPDATE" is implemented in DB2 ? (It seems to be different than "FOR UPDATE clause in Oracle)

CREATE PROCEDURE updateAndReturn ( IN input_param CHARACTER(2), OUT return_value VARCHAR(7) )

P1: BEGIN

-- select a value
SELECT bColumn INTO temp_number
FROM aTable
WHERE aColumn = input_param;

-update the value
return_value = update(temp_number)

--update the corresponding record in database.
UPDATE aTable
SET bColumn = return_value
WHERE aColumn = input_param;

END P1



Client1 CALL updateAndReturn('A', ?);
Client2 CALL updateAndReturn('A', ?);

Is there a remote possibility that both client 1 & 2 might select the same row for update?
Wherein update from some of the users might be lost.

Thanks & Regards
Bipin
Sep 10 '06 #1
1 2543
Hi,

I have a small doubt in SQL Procedures in DB2.

It is the first time that I am using DB2 UDB, so please bear me.

Following, is a very small example to put across my doubt.

In following procedure we have a select query query which returns only one row, and after some processing I update the same row.

My question is if two different clients runs the same procedure with the same input parameter, Is it every possible that procedure may return the same serial number.

How actually procedures are handled in multi user environment?

Do I need to write sql with explicit locking? (eg WITH CS, RR or RS)

How actually the "FOR UPDATE" is implemented in DB2 ? (It seems to be different than "FOR UPDATE clause in Oracle)

CREATE PROCEDURE updateAndReturn ( IN input_param CHARACTER(2), OUT return_value VARCHAR(7) )

P1: BEGIN

-- select a value
SELECT bColumn INTO temp_number
FROM aTable
WHERE aColumn = input_param;

-update the value
return_value = update(temp_number)

--update the corresponding record in database.
UPDATE aTable
SET bColumn = return_value
WHERE aColumn = input_param;

END P1



Client1 CALL updateAndReturn('A', ?);
Client2 CALL updateAndReturn('A', ?);

Is there a remote possibility that both client 1 & 2 might select the same row for update?
Wherein update from some of the users might be lost.

Thanks & Regards
Bipin
Hi
like any other program that access data in db2, your sql procedure has a package which it runs with.
that package has the isolation level parameter that defines the way the package behave with other applications (or other invokation of the same package),
or in other word,
your sql procedure is no different in that manner than any other applicaiton
Sep 14 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Berend | last post by:
I am trying to pass multi values into a where clause with an in clause in a store procedure to use in a Crystal report. This can change depending on the user. Maybe there is another way to pass...
4
by: marc | last post by:
I've been developing a stored procedure that uses a user defined function in the query portion of the procedure. However, since the end product needs to allow for dynamic table names, the UDF will...
4
by: SHPsalm139 | last post by:
If I'm in, say, a 3rd level sub and want to exit, not only the sub but the entire procedure, without a GoTo, can this be done without using switches?
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
2
by: news.sbcglobal.net | last post by:
Here's my problem: I'm developing an ASP.NET 2.0 application that has a user select one or more auto manufacturers from a listbox ("lstMakes"). Once they do this, another listbox ("lstModels")...
0
by: mirandacascade | last post by:
Apologies in advance for what I'm guessing may be a trivial question. Assume the following: 1) multi-user environment 2) standard (i.e. not a class module) module with: Public strSample as...
0
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works...
0
by: Mark C. Stock | last post by:
"Mark C. Stock" <mcstockX@Xenquery .comwrote in message news:... | | "Berend" <Berend.Brinkhuis@evatone.comwrote in message | news:bdd9ac20.0401271301.22cdb65e@posting.google.com... | | I am...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.