473,511 Members | 16,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Possible DB2 bug in the stored procedure parameters handling.

Hello, everybody.

I've noticed very strange DB2 behaviour in a stored procedure
parameters handling, and it looks like a bug for me. Consider stored
procedure defined as:

Create procedure test_proc(
IN p_x char(1),
OUT p_y char(1)
)
language sql result sets 0 modifies sql data BEGIN ...

Nothing special occurs if you make such a call from another stored
procedure:

call test_proc( var_x, var_y );

But if you pass the same variable for both parameters, like:

call test_proc( the_var, the_var );

then parameter "p_x" gets NULL value upon the entry "test_proc",
regardless of the real "the_var" value.

Why so ? Is this a bug or a feature ? Is this documented somewhere ?
I've detected this on "DB2 8.1.6 Enterprise Edition for Windows IA32".
--
Konstantin Andreev.

May 16 '06 #1
8 1917
Konstantin Andreev wrote:
Hello, everybody.

I've noticed very strange DB2 behaviour in a stored procedure
parameters handling, and it looks like a bug for me. Consider stored
procedure defined as:

Create procedure test_proc(
IN p_x char(1),
OUT p_y char(1)
)
language sql result sets 0 modifies sql data BEGIN ...

Nothing special occurs if you make such a call from another stored
procedure:

call test_proc( var_x, var_y );

But if you pass the same variable for both parameters, like:

call test_proc( the_var, the_var );

then parameter "p_x" gets NULL value upon the entry "test_proc",
regardless of the real "the_var" value.

Why so ? Is this a bug or a feature ? Is this documented somewhere ?
I've detected this on "DB2 8.1.6 Enterprise Edition for Windows IA32".
--
Konstantin Andreev.

I tried to repro like this on DB2 Viper, but was unsuccessful:

db2 => CREATE PROCEDURE P(IN a INT, OUT b INT) SET b = a;
DB20000I The SQL command completed successfully.
db2 => CREATE PROCEDURE D(INOUT c INT) CALL P(c, c);
DB20000I The SQL command completed successfully.
db2 => CALL D(5);

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : 5

Return Status = 0

Can you provide a script. Clearly what you observe sounds wrong.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 17 '06 #2
Serge Rielau писал(а):
I tried to repro like this on DB2 Viper, but was unsuccessful:

db2 => CREATE PROCEDURE P(IN a INT, OUT b INT) SET b = a;
DB20000I The SQL command completed successfully.
db2 => CREATE PROCEDURE D(INOUT c INT) CALL P(c, c);
DB20000I The SQL command completed successfully.
db2 => CALL D(5);

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : 5

Return Status = 0
I tried this, it works in my system too.
Can you provide a script. Clearly what you observe sounds wrong.

Below is the script. When called, the procedure saves it's parameters
in temporary table, and we can analyse them later. Here the call log on
my system:

X Y
------
a - the parameters of the "test_proc( x, y )" call
- - the parameters of the "test_proc( x, x )" call
------------------------------------------------------------------------------
DECLARE GLOBAL TEMPORARY TABLE #t(
x char(1), y char(1)
)
ON COMMIT PRESERVE ROWS NOT LOGGED
@
Create procedure test_proc(
IN p_x char(1),
OUT p_y char(1)
) Begin
insert into session.#t values ( p_x, p_y );
end
@
Create procedure test_wrap(
) Begin
declare x, y char(1);

values( 'a', 'b' ) into x, y;

call test_proc( x, y ); -- OK
call test_proc( x, x ); -- ERROR, ERROR !!!
end
@
call test_wrap()
@
select * from session.#t
@
drop procedure test_proc @
drop procedure test_wrap @
drop table session.#t @
------------------------------------------------------------------------------

May 17 '06 #3
Serge Rielau wrote:
db2 => CREATE PROCEDURE P(IN a INT, OUT b INT) SET b = a;
DB20000I The SQL command completed successfully.
db2 => CREATE PROCEDURE D(INOUT c INT) CALL P(c, c);
DB20000I The SQL command completed successfully.
db2 => CALL D(5);

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : 5

Return Status = 0


This approach will also fail ( successfull repro ) if you change INT to
CHAR(x):

db2 => CREATE PROCEDURE P(IN a char(10), OUT b char(10)) SET b = a
DB20000I The SQL command completed successfully.
db2 => cREATE PROCEDURE D(INOUT c char(10)) CALL P(c, c)
DB20000I The SQL command completed successfully.
db2 => call d('a')

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : -

Return Status = 0
--
Konstantin Andreev.

May 17 '06 #4
Konstantin Andreev wrote:
Serge Rielau wrote:
db2 => CREATE PROCEDURE P(IN a INT, OUT b INT) SET b = a;
DB20000I The SQL command completed successfully.
db2 => CREATE PROCEDURE D(INOUT c INT) CALL P(c, c);
DB20000I The SQL command completed successfully.
db2 => CALL D(5);

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : 5

Return Status = 0


This approach will also fail ( successfull repro ) if you change INT to
CHAR(x):

db2 => CREATE PROCEDURE P(IN a char(10), OUT b char(10)) SET b = a
DB20000I The SQL command completed successfully.
db2 => cREATE PROCEDURE D(INOUT c char(10)) CALL P(c, c)
DB20000I The SQL command completed successfully.
db2 => call d('a')

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : -

Return Status = 0
--
Konstantin Andreev.

Works on DB2 Viper. I'll inquire whether there is a known fix.
If you need a fix please open a PMR.

db2 => CREATE PROCEDURE P(IN a CHAR(10), OUT b char(10)) SET b = a;
DB20000I The SQL command completed successfully.
db2 => CREATE PROCEDURE D(INOUT c char(10)) CALL P(c, c);
DB20000I The SQL command completed successfully.
db2 => CALL D('a');

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : a

Return Status = 0

db2 =>
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 17 '06 #5
Serge Rielau писал(а):
This approach will also fail ( successfull repro ) if you change INT toCHAR(x):

db2 => CREATE PROCEDURE P(IN a char(10), OUT b char(10)) SET b = a
DB20000I The SQL command completed successfully.
db2 => cREATE PROCEDURE D(INOUT c char(10)) CALL P(c, c)
DB20000I The SQL command completed successfully.
db2 => call d('a')

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : -

Return Status = 0

Works on DB2 Viper. I'll inquire whether there is a known fix. If you need a fix please open a PMR.

db2 => CREATE PROCEDURE P(IN a CHAR(10), OUT b char(10)) SET b = a;
db2 => CREATE PROCEDURE D(INOUT c char(10)) CALL P(c, c);
db2 => CALL D('a');

Value of output parameters
--------------------------
Parameter Name : C
Parameter Value : a

Return Status = 0


Thank you a lot, Serge. Since this bug is fixed on Viper, then
everything is all right. For now I can use a workaround.
--
Konstantin Andreev.

May 17 '06 #6
"Konstantin Andreev" <dr*******@datatech.ru> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
Thank you a lot, Serge. Since this bug is fixed on Viper, then
everything is all right. For now I can use a workaround.
--
Konstantin Andreev.


Maybe it is fixed before Viper. Do you have the latest fixpack (FP11)?
May 18 '06 #7
FP 12 has been released.

May 18 '06 #8
In article <11**********************@y43g2000cwc.googlegroups .com>,
mi****@us.automatos.com says...
FP 12 has been released.


But be carefull, they made a mess of it. When downloading the Release
Notes you get the DB2 FP11 release notes. I hope the images are
correct!!
May 18 '06 #9

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

Similar topics

1
4764
by: Bill S. | last post by:
Hi, I a stored procedure that inserts a record into a table as below. The insert works OK, but if the insert violates a unique indewx constraint on one of the columns, the proc terminates...
0
6678
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
1
2118
by: M Wells | last post by:
Hi All, Further to my previous long-winded question about a situation in which we appear to be mysteriously losing data from our mssql2k server. We discovered an update statement, in the...
2
5102
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create, read, update, delete data in a SQL Server 2000 data...
6
26511
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
2
5437
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
1
3804
by: j090757 | last post by:
Returning parm data to vb.net from AS400 stored procedure This example loads a textbox which is used by javascript for error handling. First create the stored procedure on the AS400: CREATE...
2
4080
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
4
5068
by: barmatt80 | last post by:
I am stumped on the error reporting with sql server. I was told i need to return @SQLCode(code showing if successful or not) and @ErrMsg(and the message returned). I am clueless on this. I...
0
7242
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
7423
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...
0
7510
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...
0
5668
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 projectplanning, coding, testing,...
1
5066
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...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
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 ...
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.