StoredProcedure that returns an identity

Posts   
 
    
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 01-Jun-2011 23:44:07   

LLBL 3.1, SelfServicing, SqlServer

There is a stored procedure that is returning either a 0 or the id of the record inserted.

Initially, this was generated into code as an ActionProcedure that only returned a 0 or 1 for success or failure. Then I tried setting resultset to 1, but now I just get back an empty datatable.

How can I generate a wrapper for this proc that returns the true proper scalar value output of the stored procedure?

The database is NOT mine, I'm reading from it, so I can't make changes to the db.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Jun-2011 03:57:14   

My personal recommendation is: go back to ActionProcedure (resulset = 0), that way you get back the scalar result as int. ResultProcedures are for SPs that return table like resulsets.

Then you can create a method that wrap the procedure call and return a bool depending upon the 0/1 returned by the SP call.

David Elizondo | LLBLGen Support Team
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 02-Jun-2011 04:01:07   

But ActionProcedures does not return the scalar result of the stored procedure which could be ANY positive number.

ActionProcedures return ONLY a 0 or 1, the result of the call to ExecuteNonQuery

I need LLBL to generate something that internally calles ExecuteScalar.

How do I do that?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Jun-2011 12:41:15   

Can you wrap this SP in another one that returns the value in an Output Paramter?

You can find a workaround here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=18949

happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 02-Jun-2011 13:41:36   

The database is NOT ours and I'm not allowed to make any changes to it's design or add anything. It belongs to another vendor.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Jun-2011 15:39:58   

Did you check the workaround in the above mentioned link?

happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 02-Jun-2011 15:50:22   

I'm confused. The workaround is to change/wrap the proc. I don't have permissions to add another proc to the db.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 02-Jun-2011 19:30:15   

Sorry, but it looks like this is a scenario that we don't have covered. Don't forget that you don't HAVE to use LLBLGen for all of your data access... simple_smile

Matt