adodbapi return value

Discussion in 'Python' started by Nikolai Kirsebom, Apr 4, 2005.

  1. 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
    Nikolai Kirsebom, Apr 4, 2005
    #1
    1. Advertising

  2. 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
    Nikolai Kirsebom, Apr 4, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Achim Domma

    adodbapi / string encoding problem

    Achim Domma, Sep 25, 2003, in forum: Python
    Replies:
    10
    Views:
    756
    Alex Martelli
    Sep 26, 2003
  2. Sangbae

    [adodbapi] cannot create table

    Sangbae, Oct 6, 2003, in forum: Python
    Replies:
    3
    Views:
    556
    Bob Gailer
    Oct 7, 2003
  3. Raaijmakers, Vincent \(GE Infrastructure\)

    adodbapi, exception/error handling question

    Raaijmakers, Vincent \(GE Infrastructure\), Jan 20, 2004, in forum: Python
    Replies:
    0
    Views:
    425
    Raaijmakers, Vincent \(GE Infrastructure\)
    Jan 20, 2004
  4. Max Ischenko

    CoInitialize error when using adodbapi

    Max Ischenko, Feb 9, 2004, in forum: Python
    Replies:
    1
    Views:
    1,666
    Ixokai
    Feb 9, 2004
  5. Greenhorn
    Replies:
    15
    Views:
    786
    Keith Thompson
    Mar 6, 2005
Loading...

Share This Page