You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by "Michael (gmail)" <mi...@gmail.com> on 2006/06/26 21:00:38 UTC

Multiple Stored Procedures with same name (different owners) causes issues

We use MSSQL as our backend and have "checked in" stored procedures as  
owned by dbo.  As developers are working or fixing bugs, they create  
stored procedures in there own name and when finished will convert them to  
dbo so everyone can use them.  This causes errors in iBATIS.  I have  
tracked it down to the DeriveParameters function call returns a set of  
parameters for each stored procedure by the same name.  Then ibatis throws  
an ArgumentOutOfRangeException.  I have included the stack trace below.


System.Reflection.TargetInvocationException: Exception has been thrown by  
the target of an invocation. ---> System.ArgumentOutOfRangeException:  
Index was out of range. Must be non-negative and less than the size of the  
collection.
Parameter name: index
    at System.Collections.ArrayList.get_Item(Int32 index)
    at  
IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterMap.GetProperty(Int32  
index)
    at  
IBatisNet.DataMapper.Commands.DefaultPreparedCommand.ApplyParameterMap(IDalSession  
session, IDbCommand command, RequestScope request, IStatement statement,  
Object parameterObject)
    at  
IBatisNet.DataMapper.Commands.DefaultPreparedCommand.Create(RequestScope  
request, IDalSession session, IStatement statement, Object parameterObject)
    at  
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForRowDelegate(IDalSession  
session, Object parameterObject, RowDelegate rowDelegate)
    at IBatisNet.DataMapper.SqlMapper.QueryWithRowDelegate(String  
statementName, Object parameterObject, RowDelegate rowDelegate)
    at
...

I assume many people work like this.  Is there a workaround?  I relize  
this might be a MSSQL or ADO.Net issue, but it would be nice to have a  
workable solution till they can get it fixed.

Thanks

-- 
Michael Schall

Re: Multiple Stored Procedures with same name (different owners) causes issues

Posted by Michael Schall <mi...@gmail.com>.
Doing a little bit more digging looks like the culprit is
sp_procedure_params_rowset in the master database.

I pulled the text of this sp to test with and added the following and
ran as text

if exists(select * from sysobjects where name = @procedure_name and
user_name(sysobjects.uid) = user_name())
	set @procedure_schema = user_name()
else
	set @procedure_schema = 'DBO'

This give me what I want.  Has anyone changed a system stored procedure before?

Pretty sure that is a no-no.
Thoughts?
Mike

Re: Multiple Stored Procedures with same name (different owners) causes issues

Posted by Michael Schall <mi...@gmail.com>.
On 6/29/06, Chad Humphries <ch...@gmail.com> wrote:
> Do you have any prefix on the stored procedures in your sqlmaps for
> the owner?

This is a workaround for the DeriveParameters bug.  I have tested it
and things work fine.  The only issue now is having developers
rememeber to remove the prefix when switching to dbo. Any idea how we
lean on MS to fix this?

Thanks
Mike

Re: Multiple Stored Procedures with same name (different owners) causes issues

Posted by Chad Humphries <ch...@gmail.com>.
Do you have any prefix on the stored procedures in your sqlmaps for
the owner?  If not you may want to try prefixing them with the desired
owner, at least while in the development phase.   I had a problem
several months back with a server setup that required I do this type
of fix.

-Chad

On 6/29/06, Michael Schall <mi...@gmail.com> wrote:
> It does seem to match that description.  We are not using Reporting Services
> however.  So either their applies to section is wrong or we have a different
> issue.  Is there anyway for us to workaround the problem in iBATIS?  Is
> anyone else working in MSSQL2000 and not having my issue?  I would love to
> hear we just have a setting wrong on our server.
>
> Thanks for your time
> Mike
>
>

Re: Multiple Stored Procedures with same name (different owners) causes issues

Posted by Michael Schall <mi...@gmail.com>.
It does seem to match that description.  We are not using Reporting Services
however.  So either their applies to section is wrong or we have a different
issue.  Is there anyway for us to workaround the problem in iBATIS?  Is
anyone else working in MSSQL2000 and not having my issue?  I would love to
hear we just have a setting wrong on our server.

Thanks for your time
Mike

Re: Multiple Stored Procedures with same name (different owners) causes issues

Posted by Gilles Bayon <ib...@gmail.com>.
Thinks it's a MS bug
http://support.microsoft.com/kb/898086/en-us


On 6/29/06, Michael Schall <mi...@gmail.com> wrote:
>
> Is there anything else I can give you to help you troubleshoot the
> issue?  Have you been able to recreate this issue?
>
> Thanks for your time helping with this.
>
> Mike
>

Re: Multiple Stored Procedures with same name (different owners) causes issues

Posted by Michael Schall <mi...@gmail.com>.
Is there anything else I can give you to help you troubleshoot the
issue?  Have you been able to recreate this issue?

Thanks for your time helping with this.

Mike

Re: Multiple Stored Procedures with same name (different owners) causes issues

Posted by Michael Schall <mi...@gmail.com>.
MSSQL 2000 sp4

On 6/27/06, Gilles Bayon <ib...@gmail.com> wrote:
> Which MSSQL version do you used ?
>
>
>
> On 6/26/06, Michael (gmail) <mi...@gmail.com> wrote:
> > We use MSSQL as our backend and have "checked in" stored procedures as
> > owned by dbo.  As developers are working or fixing bugs, they create
> > stored procedures in there own name and when finished will convert them to
> > dbo so everyone can use them.  This causes errors in iBATIS.  I have
> > tracked it down to the DeriveParameters function call returns a set of
> > parameters for each stored procedure by the same name.  Then ibatis throws
> > an ArgumentOutOfRangeException.  I have included the stack trace below.
> >
> >
> > System.Reflection.TargetInvocationException: Exception
> has been thrown by
> > the target of an invocation. --->
> System.ArgumentOutOfRangeException:
> > Index was out of range. Must be non-negative and less than the size of the
> > collection.
> > Parameter name: index
> >    at System.Collections.ArrayList.get_Item (Int32 index)
> >    at
> >
> IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterMap.GetProperty(Int32
> > index)
> >    at
> >
> IBatisNet.DataMapper.Commands.DefaultPreparedCommand.ApplyParameterMap(IDalSession
> > session, IDbCommand command, RequestScope request, IStatement statement,
> > Object parameterObject)
> >    at
> >
> IBatisNet.DataMapper.Commands.DefaultPreparedCommand.Create(RequestScope
> > request, IDalSession session, IStatement statement, Object
> parameterObject)
> >    at
> >
> IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForRowDelegate
> (IDalSession
> > session, Object parameterObject, RowDelegate rowDelegate)
> >    at
> IBatisNet.DataMapper.SqlMapper.QueryWithRowDelegate(String
> > statementName, Object parameterObject, RowDelegate rowDelegate)
> >    at
> > ...
> >
> > I assume many people work like this.  Is there a workaround?  I relize
> > this might be a MSSQL or ADO.Net issue, but it would be nice to have a
> > workable solution till they can get it fixed.
> >
> > Thanks
> >
> > --
> > Michael Schall
> >
>
>

Re: Multiple Stored Procedures with same name (different owners) causes issues

Posted by Gilles Bayon <ib...@gmail.com>.
Which MSSQL version do you used ?

On 6/26/06, Michael (gmail) <mi...@gmail.com> wrote:
>
> We use MSSQL as our backend and have "checked in" stored procedures as
> owned by dbo.  As developers are working or fixing bugs, they create
> stored procedures in there own name and when finished will convert them to
> dbo so everyone can use them.  This causes errors in iBATIS.  I have
> tracked it down to the DeriveParameters function call returns a set of
> parameters for each stored procedure by the same name.  Then ibatis throws
> an ArgumentOutOfRangeException.  I have included the stack trace below.
>
>
> System.Reflection.TargetInvocationException: Exception has been thrown by
> the target of an invocation. ---> System.ArgumentOutOfRangeException:
> Index was out of range. Must be non-negative and less than the size of the
> collection.
> Parameter name: index
>    at System.Collections.ArrayList.get_Item(Int32 index)
>    at
>
> IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterMap.GetProperty
> (Int32
> index)
>    at
> IBatisNet.DataMapper.Commands.DefaultPreparedCommand.ApplyParameterMap
> (IDalSession
> session, IDbCommand command, RequestScope request, IStatement statement,
> Object parameterObject)
>    at
> IBatisNet.DataMapper.Commands.DefaultPreparedCommand.Create(RequestScope
> request, IDalSession session, IStatement statement, Object
> parameterObject)
>    at
>
> IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForRowDelegate
> (IDalSession
> session, Object parameterObject, RowDelegate rowDelegate)
>    at IBatisNet.DataMapper.SqlMapper.QueryWithRowDelegate(String
> statementName, Object parameterObject, RowDelegate rowDelegate)
>    at
> ...
>
> I assume many people work like this.  Is there a workaround?  I relize
> this might be a MSSQL or ADO.Net issue, but it would be nice to have a
> workable solution till they can get it fixed.
>
> Thanks
>
> --
> Michael Schall
>