Multi-task sproc

  • I have a transaction table from which I build other transactions to charge certain fees. I can create 3 sprocs to spin through this table selecting appropriate records and creating the fee transactions, with one sproc calling the other until finished. What I had hoped to do was use one sproc like this...

    Insert Into Transaction (for Fee Type 1)

    ...

    Select From ... various conditions

    Insert Into Transaction (for Fee Type 2)

    ...

    Select From ... various different conditions that make it impossible to include in the insert above

    Insert Into Transaction (for Fee Type 3

    ...

    Select From ... various different conditions that make it impossible to include in the insert above

     

    The problem I find is that only the first Insert Into statement is being executed. Do I need a "GO" between the Insert Into statements?

    Thanks,

    Bill

  • If I'm understanding you...

    Why not...

    Insert into Transaction

    --Type One

    Select ... from ...

    union all

    --Type Two

    Select ... from ...

    union all

    Select ... from ...

    HTH


    Mathew J Kulangara
    sqladventures.blogspot.com

  • In a SPROC you should be able to do multiple steps.. That being a large part of the idea.

    CREATE PROCEDURE ..

    AS

    SET NOCOUNT ON

    -- comment t1

    Insert Into Transaction (for Fee Type 1)

    SELect From ...

    --impossible to include in the insert above

    Insert Into Transaction (for Fee Type 2)

    Select From ... various different conditions that make it

    -- impossible to include in the insert above

    Insert Into Transaction (for Fee Type 3

    Select From ... various different conditions that make it

    RETURN

  • Matthew,

    Good point. I figured out the reason it wasn't working. The test team had not set a fee value in the test environment and I set the query to bypass 0 fee amounts.

    Thanks for the help.

    Bill

Viewing 4 posts - 1 through 3 (of 3 total)

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