stored procedure truncates string-parameter

25 views
Skip to first unread message

Mathias

unread,
Apr 15, 2012, 2:29:20 AM4/15/12
to ibm...@googlegroups.com
Hi,
When I call a stored procedure, which has a CHAR or VARCHAR as OUT-Parameter, this parameter is truncated:

My Stored Procedure:
--------------
CREATE PROCEDURE TEST_VARCHAR_OUT (   
     out test_out1       VARCHAR(1)
    ,out test_out2_safe  VARCHAR(2)
    ,out test_out5       VARCHAR(5)
    ,out test_out6_safe  VARCHAR(6)
    ,out test_char1      CHAR(2)
)
LANGUAGE SQL
BEGIN 
   SET test_out5        = 'ABCDE';
   SET test_out6_safe   = 'ABCDE';
   SET test_out1        = 'A';
   SET test_out2_safe   = 'A';
   SET test_char1 = 'AB';
   RETURN 0;
END
@
--------------

In Python:
>>> params = ("","","","","")
>>> import ibm_db
>>> conn = ibm_db.connect(db_name, db_user, db_pwd )
>>> ibm_db.callproc(conn, "TEST_VARCHAR_OUT", params)[1:]
('', 'A', 'ABCD', 'ABCDE', 'A')

This means, that every string is truncated by one character.
When I use other parameters, with one more character as the parameter is defined (reserving perhaps enough length to the pointer in C) it is working, like it should:
>>> params = (" "*2," "*3," "*6," "*7," "*3)
>>> ibm_db.callproc(conn, "TEST_VARCHAR_OUT", params)[1:]
('A', 'A', 'ABCDE', 'ABCDE', 'AB')
------

Can somebody confirm this behaviour or am I doing this in a not proper way?
I am working on WinXP 32 and Server is running on a linux-machine.
Python 2.6.6
IBM_DB 1.0.5

Thank you!

 



Rahul

unread,
Apr 16, 2012, 1:34:39 AM4/16/12
to ibm_db
Hi Mathias,
This one is known problem we have already have created a patch for
this.
Please download the modified ibm_db.c file from
http://ibm-db.googlecode.com/issues/attachment?aid=1000003000&name=ibm_db.c&token=Q051xJXzPKt8jCMTRr2I_jCDDjw%3A1334554044044
and replace your existing ibm_db.c file with this.

Please use it and let me know how it goes for you.

Thanks,
Rahul Priyadarshi

Mathias

unread,
Apr 16, 2012, 4:12:40 AM4/16/12
to ibm...@googlegroups.com
Thank you Rahul! 
This fixed it. I assume this fix will be part of next release?

Rahul

unread,
Apr 16, 2012, 4:18:29 AM4/16/12
to ibm_db
Yes Mathias, this fix will be the part of next release.

On Apr 16, 1:12 pm, Mathias <mathias.lege...@gmail.com> wrote:
> Thank you Rahul!
> This fixed it. I assume this fix will be part of next release?
>
> Am Montag, 16. April 2012 07:34:39 UTC+2 schrieb Rahul:
>
>
>
>
>
>
>
>
>
> > Hi Mathias,
> >  This one is known problem we have already have created a patch for
> > this.
> >  Please download the modified ibm_db.c file from
>
> >http://ibm-db.googlecode.com/issues/attachment?aid=1000003000&name=ib...

Mathias

unread,
Apr 16, 2012, 4:36:46 AM4/16/12
to ibm...@googlegroups.com
Thank you for your help!
Reply all
Reply to author
Forward
0 new messages