temp table problem?

Discussion in 'ASP General' started by Savas Ates, Oct 12, 2004.

  1. Savas Ates

    Savas Ates Guest

    i have a stored below

    it uses create temp table and drop temp table... when more than one user
    request the same page it probably returns error.. how can i solve this
    problem

    ****************************************************************************
    *****************************************
    CREATE PROCEDURE st_seconddegree
    @fromwhom numeric(18), @towhom numeric(18) AS


    SET NOCOUNT ON
    if not exists (select 1 from crosstable where (fromwhom=@fromwhom and
    towhom=@towhom ) or (fromwhom=@towhom and towhom=@fromwhom))
    Begin
    create table #pele1
    (xuserid numeric(18),xarkid numeric (18)
    )
    insert into #pele1 SELECT
    xuserid = CASE WHEN fromwhom <> @fromwhom then @fromwhom ELSE fromwhom
    END,
    xarkid = CASE WHEN fromwhom = @fromwhom then towhom ELSE fromwhom END


    FROM crosstable
    where fromwhom=@fromwhom or towhom=@fromwhom

    create table #pele2
    (xuserid numeric(18),xarkid numeric (18)
    )
    insert into #pele2
    SELECT
    xuserid = CASE WHEN fromwhom <> @towhom then @towhom ELSE fromwhom END,
    xarkid = CASE WHEN fromwhom = @towhom then towhom ELSE fromwhom END

    FROM crosstable
    where fromwhom=@towhom or towhom=@towhom

    select #pele1.xarkid as xarkid from #pele1 INNER JOIN #pele2 ON
    #pele1.xarkid=#pele2.xarkid;
    drop table #pele1
    drop table #pele2
    End
    GO
    ****************************************************************************
    **********************************************
     
    Savas Ates, Oct 12, 2004
    #1
    1. Advertising

  2. "when more than one user request the same page it probably returns error"

    Are you guessing that the stored procedure will error when multiple people
    (connections/users) call it at the same time? Temp tables are only visible
    to the connection that created them, therefore there will not be a problem
    with multiple users calling this stored procedure at the same time.

    --
    Keith


    "Savas Ates" <> wrote in message
    news:OfV4Q$...
    > i have a stored below
    >
    > it uses create temp table and drop temp table... when more than one user
    > request the same page it probably returns error.. how can i solve this
    > problem
    >
    >

    ****************************************************************************
    > *****************************************
    > CREATE PROCEDURE st_seconddegree
    > @fromwhom numeric(18), @towhom numeric(18) AS
    >
    >
    > SET NOCOUNT ON
    > if not exists (select 1 from crosstable where (fromwhom=@fromwhom and
    > towhom=@towhom ) or (fromwhom=@towhom and towhom=@fromwhom))
    > Begin
    > create table #pele1
    > (xuserid numeric(18),xarkid numeric (18)
    > )
    > insert into #pele1 SELECT
    > xuserid = CASE WHEN fromwhom <> @fromwhom then @fromwhom ELSE fromwhom
    > END,
    > xarkid = CASE WHEN fromwhom = @fromwhom then towhom ELSE fromwhom END
    >
    >
    > FROM crosstable
    > where fromwhom=@fromwhom or towhom=@fromwhom
    >
    > create table #pele2
    > (xuserid numeric(18),xarkid numeric (18)
    > )
    > insert into #pele2
    > SELECT
    > xuserid = CASE WHEN fromwhom <> @towhom then @towhom ELSE fromwhom

    END,
    > xarkid = CASE WHEN fromwhom = @towhom then towhom ELSE fromwhom END
    >
    > FROM crosstable
    > where fromwhom=@towhom or towhom=@towhom
    >
    > select #pele1.xarkid as xarkid from #pele1 INNER JOIN #pele2 ON
    > #pele1.xarkid=#pele2.xarkid;
    > drop table #pele1
    > drop table #pele2
    > End
    > GO
    >

    ****************************************************************************
    > **********************************************
    >
    >
     
    Keith Kratochvil, Oct 12, 2004
    #2
    1. Advertising

  3. > it uses create temp table and drop temp table... when more than one user
    > request the same page it probably returns error.. how can i solve this
    > problem


    This isn't a problem. Have you actually observed errors? Have you tried
    producing an error? Perhaps you should read up on temp tables...

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)
     
    Aaron [SQL Server MVP], Oct 12, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ahmed Jewahar

    Temp Table not found or Doesn't exists !!!!

    Ahmed Jewahar, Apr 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    745
    Ahmed Jewahar
    Apr 5, 2004
  2. Phil Short via DotNetMonster.com

    asp.net Oracle TEMP table woes

    Phil Short via DotNetMonster.com, Apr 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    710
    Phil Short via DotNetMonster.com
    Apr 4, 2005
  3. Replies:
    2
    Views:
    582
    Mark P
    May 9, 2005
  4. A. Farber
    Replies:
    3
    Views:
    273
    Ben Morrow
    Mar 3, 2004
  5. PerlFAQ Server
    Replies:
    0
    Views:
    269
    PerlFAQ Server
    Apr 26, 2011
Loading...

Share This Page