RE: RE: Sybase Module 0.36 Output Parameter Handling

"Bradley Feldman" <[email protected]> Thu, 17 Mar 2005 22:10:51 -0800
Newsgroups gmane.comp.python.sybase
Message-ID <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAl26AvnJDdE2pAhSiEiAYTsKAAAAQAAAAhp+/[email protected]>
What version of FreeTDS are you using?

I'm not seeing any errors like that at all.  I'm using FreeTDS 0.62.4.  See
below:

Cursor.callproc
ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd3
ct_command(cmd3, CS_RPC_CMD, "sp_test_output", CS_NULLTERM, CS_UNUSED) ->
CS_SUCCEED
ct_param(cmd3, &databuf0->fmt=[name:"@result" type:CS_INT_TYPE
status:CS_RETURN format:CS_FMT_UNUSED count:1 maxlength:4 scale:0
precision:0], databuf0->buff, 4, 0) -> CS_SUCCEED
ct_param(cmd3, &databuf1->fmt=[name:"@num" type:CS_INT_TYPE
status:CS_INPUTVALUE format:CS_FMT_UNUSED count:1 maxlength:4 scale:0
precision:0], databuf1->buff, 4, 0) -> CS_SUCCEED
ct_send(cmd3) -> CS_SUCCEED
ct_results(cmd3, &result) -> CS_SUCCEED, CS_STATUS_RESULT
ct_res_info(cmd3, CS_NUMDATA, &value, CS_UNUSED, NULL) -> CS_SUCCEED, 1
ct_describe(cmd3, 1, &fmt) -> CS_SUCCEED, datafmt0=[name:"" type:CS_INT_TYPE
status:CS_FALSE format:CS_FMT_UNUSED count:1 maxlength:4 scale:0
precision:0]
ct_bind(cmd3, 1, &datafmt0->fmt=[name:"" type:CS_INT_TYPE status:CS_FALSE
format:CS_FMT_UNUSED count:1 maxlength:4 scale:0 precision:0],
databuf2->buff, databuf2->copied, databuf2->indicator) -> CS_SUCCEED,
databuf2
_fetch_rows
ct_fetch(cmd3, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) -> CS_SUCCEED, 1
_fetch_rows
ct_fetch(cmd3, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) -> CS_END_DATA,
0
ct_results(cmd3, &result) -> CS_SUCCEED, CS_PARAM_RESULT
ct_res_info(cmd3, CS_NUMDATA, &value, CS_UNUSED, NULL) -> CS_SUCCEED, 1
ct_describe(cmd3, 1, &fmt) -> CS_SUCCEED, datafmt1=[name:"@result"
type:CS_INT_TYPE status:CS_FALSE format:CS_FMT_UNUSED count:1 maxlength:4
scale:0 precision:0]
ct_bind(cmd3, 1, &datafmt1->fmt=[name:"@result" type:CS_INT_TYPE
status:CS_FALSE format:CS_FMT_UNUSED count:1 maxlength:4 scale:0
precision:0], databuf3->buff, databuf3->copied, databuf3->indicator) ->
CS_SUCCEED, databuf3
ct_fetch(cmd3, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) -> CS_SUCCEED, 1
ct_fetch(cmd3, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) -> CS_END_DATA,
0
ct_results(cmd3, &result) -> CS_SUCCEED, CS_CMD_SUCCEED
ct_results(cmd3, &result) -> CS_SUCCEED, CS_CMD_DONE
ct_results(cmd3, &result) -> CS_END_RESULTS, CS_FALSE
{'@num': 12345, '@result': <DataBufType object at 0x2a95596770>}
Cursor.callproc
ct_cmd_drop(cmd3) -> CS_SUCCEED
ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd4
ct_command(cmd4, CS_RPC_CMD, "sp_test_output", CS_NULLTERM, CS_UNUSED) ->
CS_SUCCEED
ct_param(cmd4, &databuf5->fmt=[name:"" type:CS_INT_TYPE status:CS_INPUTVALUE
format:CS_FMT_UNUSED count:1 maxlength:4 scale:0 precision:0],
databuf5->buff, 4, 0) -> CS_SUCCEED
ct_param(cmd4, &databuf4->fmt=[name:"" type:CS_INT_TYPE status:CS_RETURN
format:CS_FMT_UNUSED count:1 maxlength:4 scale:0 precision:0],
databuf4->buff, 4, 0) -> CS_SUCCEED
ct_send(cmd4) -> CS_SUCCEED
ct_results(cmd4, &result) -> CS_SUCCEED, CS_STATUS_RESULT
ct_res_info(cmd4, CS_NUMDATA, &value, CS_UNUSED, NULL) -> CS_SUCCEED, 1
ct_describe(cmd4, 1, &fmt) -> CS_SUCCEED, datafmt2=[name:"" type:CS_INT_TYPE
status:CS_FALSE format:CS_FMT_UNUSED count:1 maxlength:4 scale:0
precision:0]
ct_bind(cmd4, 1, &datafmt2->fmt=[name:"" type:CS_INT_TYPE status:CS_FALSE
format:CS_FMT_UNUSED count:1 maxlength:4 scale:0 precision:0],
databuf6->buff, databuf6->copied, databuf6->indicator) -> CS_SUCCEED,
databuf6
_fetch_rows
ct_fetch(cmd4, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) -> CS_SUCCEED, 1
_fetch_rows
ct_fetch(cmd4, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) -> CS_END_DATA,
0
ct_results(cmd4, &result) -> CS_SUCCEED, CS_PARAM_RESULT
ct_res_info(cmd4, CS_NUMDATA, &value, CS_UNUSED, NULL) -> CS_SUCCEED, 1
ct_describe(cmd4, 1, &fmt) -> CS_SUCCEED, datafmt3=[name:"" type:CS_INT_TYPE
status:CS_FALSE format:CS_FMT_UNUSED count:1 maxlength:4 scale:0
precision:0]
ct_bind(cmd4, 1, &datafmt3->fmt=[name:"" type:CS_INT_TYPE status:CS_FALSE
format:CS_FMT_UNUSED count:1 maxlength:4 scale:0 precision:0],
databuf7->buff, databuf7->copied, databuf7->indicator) -> CS_SUCCEED,
databuf7
ct_fetch(cmd4, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) -> CS_SUCCEED, 1
ct_fetch(cmd4, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) -> CS_END_DATA,
0
ct_results(cmd4, &result) -> CS_SUCCEED, CS_CMD_SUCCEED
ct_results(cmd4, &result) -> CS_SUCCEED, CS_CMD_DONE
ct_results(cmd4, &result) -> CS_END_RESULTS, CS_FALSE
[54321, <DataBufType object at 0x2a95596940>]
ct_cmd_drop(cmd4) -> CS_SUCCEED
ct_con_props(conn0, CS_GET, CS_CON_STATUS, &value, CS_UNUSED, NULL) ->
CS_SUCCEED, CS_CONSTAT_CONNECTED
ct_close(conn0, CS_OPT_STATS_IO) -> CS_SUCCEED
ct_con_drop(conn0) -> CS_SUCCEED

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Dave Cole
Sent: Thursday, March 17, 2005 10:00 PM
To: [email protected]
Subject: Re: [python-sybase] RE: Sybase Module 0.36 Output Parameter
Handling


Dave Cole wrote:
> Dave Cole <[email protected]>Dave Cole
> <[email protected]>Dave Cole wrote:
> 
>> I just installed ASE 12.5.2 on my machine so I could do some testing.
>> It appears there is a problem with the Cursor.callproc() method, but 
>> only when you use a sequence to pass parameters.  Dictionary 
>> parameters are fine.
>>
>> The attached sp_test.py program shows my testing.
>>
>> This program produces the following output (after applying the
>> attached callproc.patch to fix sequence argument passing).
>>
>> {'@num': 12345, '@result': 12345}
>> [54321, 54321]
>>
>> If I remove the comment character from the code that enables the
>> debugging I get the output contained in the attached sp_test.log.
>>
>> So if it is not working with FreeTDS then they are doing something
>> slightly differently that is either confusing my code or is incorrect.
> 
> 
> I just installed FreeTDS 0.61 (Debian sarge) and the test program 
> fails
> to run.  The ct_param() functions fail.  What I did discover was that 
> you can fudge it like this:
> 
> print db.execute('''
> declare @result int
> exec sp_test_output 12345, @result output
> select @result
> ''')
> 
> It prints the following:
> [[], [(12345,)]]
> 
> I am now downloading the current cvs snapshot for FreeTDS to see if 
> they
> have fixed parameter passing.

I just downloaded and installed the CVS snapshot.  With the original 
test program it appears to send the parameters to the server but fails 
with a server message.

Looking at the debug log:

Cursor.callproc
ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd3
ct_command(cmd3, CS_RPC_CMD, "sp_test_output", CS_NULLTERM, CS_UNUSED) 
-> CS_SUCCEED
ct_param(cmd3, &databuf0->fmt=[name:"@result" type:CS_INT_TYPE 
status:CS_RETURN format:CS_FMT_UNUSED count:1 maxlength:4 scale:0 
precision:0], databuf0->buff, 4, 0) -> CS_SUCCEED ct_param(cmd3,
&databuf1->fmt=[name:"@num" type:CS_INT_TYPE 
status:CS_INPUTVALUE format:CS_FMT_UNUSED count:1 maxlength:4 scale:0 
precision:0], databuf1->buff, 4, 0) -> CS_SUCCEED


So it appears that parameters are being accepted by FreeTDS but from the 
next debug lines, they are not being sent correctly.


ct_send(cmd3) -> CS_SUCCEED
servermsg_cb
Msg 245, Level 16, State 1, Procedure sp_test_output
Domain error during implicit conversion of DECIMAL value '' to a INT field.
servermsg_cb Msg 245, Level 16, State 1, Procedure sp_test_output Domain
error during implicit conversion of DECIMAL value '' to a INT field.
ct_results(cmd3, &result) -> CS_SUCCEED, CS_STATUS_RESULT ct_cancel(conn0,
NULL, CS_CANCEL_ALL) -> CS_SUCCEED Traceback (most recent call last):
   File "a.py", line 21, in ?
     r = c.callproc('sp_test_output', {'@num': 12345, '@result': 
Sybase.OUTPUT(1)})
   File "/usr/lib/python2.3/site-packages/Sybase.py", line 718, in callproc
     self.description = fetcher.start(self.arraysize, out_params)
   File "/usr/lib/python2.3/site-packages/Sybase.py", line 391, in start
     return _FetchNow.start(self, arraysize)
   File "/usr/lib/python2.3/site-packages/Sybase.py", line 315, in start
     raise e
Sybase.DatabaseError: Msg 245, Level 16, State 1, Procedure sp_test_output
Domain error during implicit conversion of DECIMAL value '' to a INT field.
Msg 245, Level 16, State 1, Procedure sp_test_output Domain error during
implicit conversion of DECIMAL value '' to a INT field.

Even more worrying is that the fudge in the previous message no longer 
works.  I get crap back.

Oh well, looks like I can wait for another couple of FreeTDS releases 
before trying again...

- Dave

-- 
http://www.object-craft.com.au
_______________________________________________
Python-sybase mailing list [email protected]
https://www.object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase