Nesting Stored Procedures

  • I understand that I can use stored procedures from another stored procedure quite happily and merrily and have done so many times in the last 2 months.

    What I'm really struggling with, though, is how to get a handle on the results from said stored procedure within the calling procedure.

    A stored procedure can return a results table, a scalar value or nothing and VB handles those result sets perfectly well.

    But when I try to use those exact same procedures (and let's face it; isn't that the main point of a stored procedure?) in another stored procedure I find it very, VERY difficult to access any part of the result except the return code.

    So far the only stored procedures I've been able to use really properly are "action only" procedures with NO returned results.

    If I want to see the result of the SP the only option I've found for doing so is to do an insert into a table variable; which has to be defined with every field coming back from the procedure because there's no means to select the fields you want before inserting them. Not only is that an incredible pain in the rear but it's also a huge violation of best practices for any RDBMS because it means you can't add fields to the result table without amending every procedure that calls it.

    Isn't there some way; even if it means adding an intervening object, that will allow me to use the results of a stored procedure just like the results of a SELECT statement the way VB does?

  • Assistance, or recommendations on the correct terminology to use with nested procedures.  Our department has an extremely bad habit of using incorrect terminology to describe things, and double that with no standardization of those terms (in other words, different teams use different terms for the same thing), it can drive one insane and make attempting to explain something difficult at times.

    What would you say is the correct terms, or most common terms, used to describe nested procedures?

    (1) The primary procedure that is executed and call the other procedure.

    (2) The procedure that is called by the primary procedure.

    I am just not finding much about it online, or I am just not searching using the correct words.  lol

    Is it 1/2, child/parent, nested/core, nest/main.....

    I do not like child/parent, because to me that infers a different type of relationship.  Maybe I am wrong, but it is just a gut feeling.  lol

    In this example too, we are doing this to centralize the code.  In other words, we have one db/location where the main procedure is stored.  Then in other db's we have a local procedure and a synonym that calls the main procedure.  This way, if we need to update or change the code, we only have to do it in one location.

    And if you have another suggestion or method, I am more than willing to take ideas.

    Thanks in advance yinz guys!

    Lance

    Analytics, Data, & Other Things

Viewing 2 posts - 31 through 31 (of 31 total)

You must be logged in to reply to this topic. Login to reply