Feedback:

Make last statement in stored procedure be the result

Make last statement in stored proc be the result, no need to populate output table.

45 votes
Vote 0 votes Vote Vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    I agree to the terms of service

    You'll receive a confirmation email with a link to create a password (optional).

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    jeremym1234jeremym1234 shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →
    planned

    5 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      I agree to the terms of service

      You'll receive a confirmation email with a link to create a password (optional).

      Signed in as (Sign out)
      Submitting...
      • AlexWongAlexWong commented  ·   ·  Flag as inappropriate

        nightcrawler,
        I think that may be a viable solution. My concern was with statement such as: "SELECT * FROM ( EXECUTE PROCEDURE xxx()) t". In such case, the query engine needs to know the data types of the stored procedure output to process the query.
        If my understand your suggestion correctly, then we will have two types of stored procedures. One type (the existing type) has predefined output parameters, and a new type that has no predefined output. The new type of stored procedure, the ones that has undefined output, will not be allowed in place of table input like the sample statement above.

      • nightcrawlernightcrawler commented  ·   ·  Flag as inappropriate

        Alex,
        I'd not pre-define the output parameters. Given the case that you want to create some kind of temp table inside the stored procedure to make some fancy stuff like a Pivot table - there's no way to predict the output parameters. They could be that different, dependant on the data, not on a structure.
        What about defining the output table if wanted and just give that back if no SELECT (or EXECUTE PROCEDURE) was the last of the statement?
        iow if no output cursor was given, do an implicit "SELECT * FROM __output".

      • AlexWongAlexWong commented  ·   ·  Flag as inappropriate

        We need some clarification on this.

        Are the output parameters still needed to be defined? I think that the answer is yes. And the select list of the last statement must match the output parameter list of the stored procedure.

      Knowledge Base and Helpdesk