Can't find stored procedure

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 13-May-2006 21:49:41   

Hi,

I have a call to an action stored procedure which is compiling fine excepty when its run I get the error...

'Could not find stored procedure 'emda_cms2.dbo'.'

The sp is called 'sp_CaseStudies#SetLiveStatus'!

Cheers, I.

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 13-May-2006 22:13:56   

Have a look at the following thread http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=364&HighLight=1.

If this does not solve the problem, please feel free to 'come back'

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 13-May-2006 22:29:51   

Fraid I'm back.

The designer can find the sp and I can call it from generated code. Its just when the code runs it gives the error.

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 13-May-2006 22:52:12   

What is the error.

It would also be useful if you could provide the version of library you are using and the stack dump.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 14-May-2006 11:52:04   

Also, the generated code contains the name of hte procedure. Is it specified there correctly or not? Do you use name overwriting for catalogs/schemas? What's the runtime/llblgenpro version you're using?

Frans Bouma | Lead developer LLBLGen Pro
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 15-May-2006 00:12:38   

public virtual int CallActionStoredProcedure(string storedProcedureToCall, SqlParameter[] parameters) { DynamicQueryEngine dqe = (DynamicQueryEngine)CreateDynamicQueryEngine(); string procName = dqe.GetNewPerCallStoredProcedureName(storedProcedureToCall); procName = DynamicQueryEngine.GetNewStoredProcedureName(procName);

        SqlCommand command = new SqlCommand(procName);

'GetNewPerCallStoredProcedureName' is removing the sp name. I'm hoping this enough for you to go on.

I don't know what name overwriting is and I'm using 1.0.2005.1 designer and net1.1 support classes.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-May-2006 15:08:12   

To get the the runtime/llblgenpro version: SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll -> rightClick -> properties -> version -> File version

A stack trace of the error/exception would be of much help.

And check the LLBLGen Pro manual documentation "Using the generated code -> Application configuration through .config files" for name overwriting for catalogs/schemas.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 15-May-2006 21:42:38   

It might be the # in the proc name which causes this problem. The name is chopped up by a regexp to determine the various parts of the name and to see which parts have to be replaced by new names (if applicable).

I'll see if I can reproduce it here with a proc which has a '#' in the name...

Frans Bouma | Lead developer LLBLGen Pro
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 15-May-2006 22:46:54   

It might be the # in the proc name which causes this problem.

Yes I'm pretty sure it is.

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 16-May-2006 00:50:51   

I can't really show you the stack trace because the renaming of the sp isn't generating an error.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 16-May-2006 11:39:11   

I can reproduce it, when the proc is represented as: "[emda_cms2].[dbo].[sp_CaseStudies#SetLiveStatus]"

using this code:


/// <summary>
/// Tests to see if wacky names aren't butchered by the name mangling code for name overwriting
/// </summary>
[Test]
public void ProcNameManglingWithWackyProcNameTest()
{
    string procName = "[emda_cms2].[dbo].[sp_CaseStudies#SetLiveStatus]";
    DataAccessAdapter adapter = new DataAccessAdapter();
    string newName = adapter.ProcNameChanger(procName);
    Assert.AreEqual(procName, newName);
}

where ProcNameChanger is:
public string ProcNameChanger(string storedProcedureToCall)
{
    DynamicQueryEngine dqe = (DynamicQueryEngine)CreateDynamicQueryEngine();
    string procName = dqe.GetNewPerCallStoredProcedureName(storedProcedureToCall);
    procName = DynamicQueryEngine.GetNewStoredProcedureName(procName);
    return procName;
}

When I specify the proc without '[]', it works. Clearly a regexp thing. I'll see if I can get this fixed.

As a workaround: please use proper procedure names. Characters like '#' arent recommended for proc names, the same goes for the sp_ prefix: use another prefix than sp, as SqlServer will then always first search the system databases for a presence of the proc if you use a prefix of 'sp'. Use pr_ or something instead.

Btw the regexp is: ((?<catalogName>[[\w.]+]|\w+(?=.)).)?(?<schemaName>[[\w.]+]|\w+).(?<procName>[[\w.]+])

and what goes wrong is that the schema name is matched by the catalogname group, the procname till the # is matched with the schema name. Now, adding the '#' character to the match groups is not that hard, though it's of course just a matter of time till someone comes with the request that other characters have to be added as well. I'll see if I can find a list of allowed characters in procnames.

Ok, the list is: @, #, $ and _. That, with normal characters and numbers, the rest is not allowed.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 16-May-2006 12:21:43   

Fixed in next build.

Frans Bouma | Lead developer LLBLGen Pro