adodbapi return value

  • Thread starter Nikolai Kirsebom
  • Start date
N

Nikolai Kirsebom

I'm trying to use the adodbapi module, but run into the following
problem:

After initalization (connection, cursor) I have the following call to
a stored procedure (SQL Server, using SQLOLEDB.1 provider).

m = u'BrReg'
rs = u''
msg = u''
x = self.cur.callproc('__DocFetchBaseCategories', (0, 0, m, rs, msg))
print x
[0, 0, u'BrReg', u'', u''] print self.cur.returnValue
None print self.cur.rowcount
-1

The procedure is enclosed below. Strange thing is that if the
variable 'm' is set to an empty string, everything works ok, the
resultstate value (x[3]) becomes '_OK'. However having the variable
'm' set to 'BrReg' as indicated, seems to result in the returned set
(x) not being updated. When executing the Stored Procedure in Query
Analyzer, everything seems to be ok (BrReg is a valid value and
results in both '_OK' resultstate and a set of values (record set)).

When using the value m='', the returnValue when printed is 0.

---------------------------- FRAGMENT OF SQL CODE --------------------
create proc __DocFetchBaseCategories (
@TraceLevel int,
@UserId int,
@Module varchar(32),
@Resultstate varchar(121) output,
@Message varchar(255) output
) as
begin
if @Module <> ''
begin
select 10000,
C.Category,
C.BaseCategory,
C.CategoryDescription
from _DerivedCategories D, _Categories C
where D.Category like (@Module + '[_]%')
and not D.BaseCategory like (@Module + '[_]%')
and D.DerivedLevel = 1
and D.Category = C.Category
end
else
begin
select 10000,
Category,
BaseCategory,
CategoryDescription
from _Categories
where BaseCategory = ''
end

select @ResultState = '_OK',
@Message = ''

NormalExit:

end

--------------------------------------------------------------------------------------------
The connection object reports 0 ADOerrors when I use the method
printADOerrors on the connection object.

Any help is appreciated.


Nikolai Kirsebom
 
N

Nikolai Kirsebom

Found out what's wrong. The "Output Parameter Availablity" property
of the connection has the value DBPROPVAL_OA_ATROWRELEASE. By closing
the record set (reading out the result set first) the output
parameters were correct. Made the modification directly in the
executeHelper method of the Cursor object. Changed at the end of the
method;

if isStoredProcedureCall and parameters != None:
return self._returnADOCommandParameters(self.cmd)

to

if isStoredProcedureCall and parameters != None:
x = self.fetchall()
rs.Close()
return self._returnADOCommandParameters(self.cmd), x

Guess this is not the right way. Any comments appreciated.
Nikolai Kirsebom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top