CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006
    Location
    Athens, Greece
    Posts
    111

    Insert Into...in Store Prcedure with variable

    hello

    i have this store procedure...

    CREATE PROCEDURE [dbo].[RC] AS
    select count(*) as Resulte from calls_pool
    GO

    it returns me the recordcount of the table calls pool.

    also i have this procedure...

    CREATE PROCEDURE [dbo].[inserta] AS

    declare @return bigint
    exec @return=RC

    insert into oop (aaa) values (@return)
    GO

    into the procedure inserta, i want to load to the variable @return the recordcount (like function). then i want to insert this value to the table oop... but into the table stores me the value 0... if i replace the setence :
    "insert into oop (aaa) values (@return)"

    with the setence

    "PRINT 'The sp returned: ' + convert(char(2),@return)" it work normal!

    why is happend????

    Thanks
    Good Luck
    -------------------*-------------------*------------------------
    Today we will see how we can develop:

    Ingredients:

    Espresso, cigarettes and lounge music
    -----------------------------------------------------------------
    Please remember to rate the posts and threads that you find useful

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Insert Into...in Store Prcedure with variable

    Change your first procedure so that it is able to return value once it checks the count

    PHP Code:
    CREATE PROCEDURE [dbo].[RC] AS
    return (
    select count(*) as Resulte from calls_pool)
    GO 
    That should solve your problem.

  3. #3
    Join Date
    Feb 2006
    Location
    Athens, Greece
    Posts
    111

    Resolved Re: Insert Into...in Store Prcedure with variable

    it works!

    i know for the return value but i think it's very stupit to return the value twice....
    it was the only thing that i don't try for the upper reason....

    Thanks a lot Shuja!
    Good Luck
    -------------------*-------------------*------------------------
    Today we will see how we can develop:

    Ingredients:

    Espresso, cigarettes and lounge music
    -----------------------------------------------------------------
    Please remember to rate the posts and threads that you find useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured