Temporary Table/Cursor Problem

I am in the process of migrating a bunch of Sybase stored procedures to Oracle. In several of them, I am using Sybase temporary tables to store data and use it in the where clause of later select statements. I thought that possibly Oracle cursor or ref cursors could do the job, but I'm having trouble getting anything to work right. Can anyone point me in the right direction? Here is an example of what I'm working with...
-- This is what was formerly being kept in a
-- Sybase temporary table
OPEN c_temp_best_offers FOR
SELECT
request.request_id,
proposal.originator_request_id,
proposal.target_request_id,
proposal.price,
proposal.date_submitted
FROM
request,
proposal,
request_type
WHERE
request.request_type_id = request_type.request_type_id AND
request.request_id = proposal.originator_request_id AND
request_type.matching_request_type_id = v_my_request_type_id
Now I need to somehow use that data in the from and where clauses of a select statement. Any help will be much appreciated.
AJ

That does help very much, thanks a lot!
However, one question remains. What if the data you named 'ss1' needs to be used in another select statement later in the stored procedure. It would appear that I would have to use that parenthesized select statement form again. Is there a more efficient way to handle that? Again, thanks for your help thus far, it is greatly appreciated...
AJ

Similar Messages

  • Temporary table refresh problem

    Hi,
    I running a process before validation on a page to populate a temporary table when I click a button.
    On the following page I've built a shuttle on the temporary table. Not the most elegant solution, but the shuttle LOV box wouldn't process the oracle text commands in the SQL.
    I'm not getting any error, but I have an unusual problem
    It takes two passes for the data to be replaced. i.e I enter 'ABCD' in the filter and it returns data with 'ABCD'
    If I return to the page and change the filter to 'EFGH' I still get 'ABCD'. I return to the page and click the button again and I get 'EFGH' results
    I've checked the data in the temporay table and that is updating in line with the problem.
    I've looked at the debug and that seems fine (i.e I can see the changed filter value), I've tried moving the truncate to a different process, that didn't help.
    I've run it in SQL developer and it seems to work fine.
    I've included the code below, but I can't see a problem with it.
    Can anybody help?
    begin
    EXECUTE IMMEDIATE('TRUNCATE TABLE temp_cat');
    commit;
    if length(:P26_ADD_FILTER) > 0 then
    insert into temp_cat (core_cat_id, core_cat_code, core_cat_desc)
    select core_cat_id,core_cat_code,core_cat_desc from core_cat where CONTAINS (core_cat_desc, '
    <query>
    <textquery lang="ENGLISH" grammar="CONTEXT">&P26_ADD_FILTER.
    <progression>
    <seq><rewrite>transform((TOKENS, "{", "}", " "))</rewrite></seq>
    <seq><rewrite>transform((TOKENS, "{", "}", " ; "))</rewrite></seq>
    <seq><rewrite>transform((TOKENS, "{", "}", "AND"))</rewrite></seq>
    <seq><rewrite>transform((TOKENS, "{", "}", "ACCUM"))</rewrite></seq>
    </progression>
    </textquery>
    <score datatype="INTEGER" algorithm="COUNT"/>
    </query>')>0 and core_cat_id not in (select pipe_project_cat.core_cat_id from pipe_project_cat where txtpamref = :p26_pamref);
    else
    insert into temp_cat (core_cat_id, core_cat_code, core_cat_desc)
    select core_cat_id,core_cat_code,core_cat_desc from core_cat where
    core_cat_id not in (select pipe_project_cat.core_cat_id from pipe_project_cat where txtpamref = :p26_pamref);
    end if;
    end;
    Edited by: jlynch on 24-Mar-2009 10:59
    Edited by: jlynch on 24-Mar-2009 11:00

    Sorry Please igonre - wrong forum!

  • Need help recreating this in Oracle (Temporary Table and a Cursor)

    Hey all,
    My client has asked me to see if it's possible to move his SQL Queries into Oracle, and then move EVERYTHING off of MSSQL into this new oracle environment. The problem is, I wrote the entire MSSQL system, and i know nothing about Oracle.
    Basically, I need some examples. I have been stumbling around Oracle for about a year now, so i'm 'somewhat' familiar with it.
    Basically, i'm going to create a script/stored procedure that will first:
    Create and define a temporary table that is used when the script/proc is called.
    Then, thru cursors, i'm going to add a bunch of lines to it.
    Finally, i'm going to Run a select statement against the temporary table we created.
    Now, I can't create a table on the server, as the production environment will not allow it, so i need to be able to create this virtually inside the script, and then it automatically self destructs at the end of the script.
    If anyone knows if this is possible, please post me a few links to examples, or just lay down the code to get the temprary table made.
    We're using TOAD as the interface.
    Thanks,
    Dan

    Thank you for the warm welcome.
    The SQL looks something like this:
    (Before you get lost in the code, this is an abreviation of the code, but every function is represented. This will also work in TOAD Script? I'm most worried about the use of how a Table is declared in Oracle, as i've seen many different versions of how to do this. Thanks)
    ~Dan
    Declare @AREA nvarchar(50)
    Declare @tmpTable Table (
         [AC_PROPERTY_ID] [INT] NULL,
         [PROPNUM] [nvarchar](50) NULL,
         [SORT_ORDER] [INT] NULL,
         [IS_TOTAL] [BIT] NULL,
         [FIELD] [nvarchar](200) NULL,
    [AREA] [nvarchar](200) NULL,
         [ENG] [nvarchar](200) NULL,
         [RSV_CAT] [nvarchar](200) NULL,
         [WELL_NAME] [nvarchar](200) NULL,
         [SHORTS_PROGRAM] [nvarchar](15) NULL,
         [SHORT_MO] [nvarchar](6) NULL,
         [SHORTS_YR] [nvarchar](6) NULL,
         [SHORTS_DESC] [nvarchar](100) NULL)
    Insert Into @tmpTable ([AC_PROPERTY_ID],[PROPNUM],[FIELD],[AREA],[ENG],[RSV_CAT],[WELL_NAME],[SHORTS_PROGRAM],[SHORT_MO],[SHORTS_YR],[SHORTS_DESC])
    Select AC_PROPERTY_ID],[PROPNUM],[FIELD],[AREA],[ENG],[RSV_CAT],[WELL_NAME],[SHORTS_PROGRAM],[SHORT_MO],[SHORTS_YR],[SHORTS_DESC] from dbo.someoldtablenameimadeup where propnum>1000
         DECLARE idcursor cursor
         FOR
         Select Distinct AREA
         from @tmpTable
         Open idcursor
         Fetch Next from idcursor into @AREA
              While (@@FETCH_STATUS <> -1)
                   BEGIN
                   IF (@@FETCH_STATUS <> -2)
                        <Do stuff for each record in the cursor>
              FETCH NEXT FROM idcursor INTO @AREA
              END
              CLOSE idcursor
              DEALLOCATE idcursor

  • PL/SQL block to create temporary table + load via cursor for loop

    Assume I have a table that contains a subset of data that I want to load into a temporary table within a cursor for-loop. Is it possible to have a single statement to create the table and load based on the results of the fetch?
    I was thinking something like:
    Declare CURSOR xyz is
    CREATE TABLE temp_table as
    select name, rank, serial number from
    HR table where rank = 'CAPTAIN'
    BEGIN
    OPEN xyz
    for name in xyz
    LOOP
    END LOOP
    What I see wrong with this is that the table would be created multiple times which is why this syntax is not acceptable. I'd prefer not to have to define the temporary table then load in two sepearte SQL statements and am hoping a single statement can be used.
    Thanks!

    What is the goal here?
    If you're just going to iterate over the rows that are returned in a cursor, a temporary table is unnecessary and only adds complexity. If you truly need a temporary table, you would declare it exactly once, at install time when you create all your other tables. You'd INSERT data into the temp table and the data would only be visible to the session that inserted it.
    Justin

  • Problem with temporary table refresh

    Hi,
    I running a process before validation on a page to populate a temporary table when I click a button.
    On the following page I've built a shuttle on the temporary table. Not the most elegant solution, but the shuttle LOV box wouldn't process the oracle text commands in the SQL.
    I'm not getting any error, but I have an unusual problem
    It takes two passes for the data to be replaced. i.e I enter 'ABCD' in the filter and it returns data with 'ABCD'
    If I return to the page and change the filter to 'EFGH' I still get 'ABCD'. I return to the page and click the button again and I get 'EFGH' results
    I've checked the data in the temporay table and that is updating in line with the problem.
    I've looked at the debug and that seems fine (i.e I can see the changed filter value), I've tried moving the truncate to a different process, that didn't help.
    I've run it in SQL developer and it seems to work fine.
    I've included the code below, but I can't see a problem with it.
    Can anybody help?
    begin
    EXECUTE IMMEDIATE('TRUNCATE TABLE temp_cat');
    commit;
    if length(:P26_ADD_FILTER) > 0 then
    insert into temp_cat (core_cat_id, core_cat_code, core_cat_desc)
    select core_cat_id,core_cat_code,core_cat_desc from core_cat where CONTAINS (core_cat_desc, '
    <query>
    <textquery lang="ENGLISH" grammar="CONTEXT">&P26_ADD_FILTER.
    <progression>
    <seq><rewrite>transform((TOKENS, "{", "}", " "))</rewrite></seq>
    <seq><rewrite>transform((TOKENS, "{", "}", " ; "))</rewrite></seq>
    <seq><rewrite>transform((TOKENS, "{", "}", "AND"))</rewrite></seq>
    <seq><rewrite>transform((TOKENS, "{", "}", "ACCUM"))</rewrite></seq>
    </progression>
    </textquery>
    <score datatype="INTEGER" algorithm="COUNT"/>
    </query>')>0 and core_cat_id not in (select pipe_project_cat.core_cat_id from pipe_project_cat where txtpamref = :p26_pamref);
    else
    insert into temp_cat (core_cat_id, core_cat_code, core_cat_desc)
    select core_cat_id,core_cat_code,core_cat_desc from core_cat where
    core_cat_id not in (select pipe_project_cat.core_cat_id from pipe_project_cat where txtpamref = :p26_pamref);
    end if;
    end;

    Hi,
    Apex does not work well with temporary tables as you cannot guarantee which session from the pool will be used to serve each page.
    In your case, it looks like the second page is using temporary data from the wrong session.
    Have you considered using Apex Collections instead?
    Luis

  • Problem with global temporary table in Oracle 10g

    Hi All,
    I face a peculiar problem in Oracle 10g with respect to Global temporary table.
    Have Oracle 10g version in Production and 11g version in UAT.
    Table_
    create global temporary table TT_TEMPGPSMANUAL
      Col_1    VARCHAR2(50),
      Col_2    VARCHAR2(500),
      Col_3    VARCHAR2(50),
      Col_4    VARCHAR2(50),
      Col_5    VARCHAR2(15),
      Col_6    VARCHAR2(20),
      Col_7    VARCHAR2(250),
      Col_8    VARCHAR2(20),
      Col_9    VARCHAR2(15),
      Col_10   VARCHAR2(20),
      Flag     NUMBER,
      Col_11   INTEGER,
      Col_12   VARCHAR2(50)
    on commit preserve rows;So this should preserve the rows inserted into this table until the session ends.
    Have a webpage in front-end where in turn, it opens another page (session is carried through) and a few rows will be inserted to this table from the webpage (through a function) on submit and the current page will be closed.
    From the parent page, if I open the sub-page data inserted in the temporary table are held and displayed (another function to fetch the values in the Global Temp table).
    The Problem in Oracle 10g (Production) is, this is not happening properly. When I close and open the sub-page, not every time I get the data stored i.e if I close and open the page 10 times, atelast 4 times the data is missed in the page (I am not getting values from temp table) randomly.
    But this does not happen in UAT (which has Oracle 11g installed) as I get the data in the webpage consistently. After passing UAT, when we rolled out to Prod, getting this issue which we are unable to get what could be the reason.
    It is very hard to debug using GTT dynamically in prod. It takes time to get Oracle 11g installed in Prod.
    Can anyone suggest?
    Regards
    Deep

    935195 wrote:
    Also, I am opening the sub-page from the parent page (through a hyperlink). Then in this case, Would session will be changed from parent to subpage? (I am not aware exactly and have the impression that, as the second page is a child, I guess it would take the same session).I'm not sure what "sub-page" or "parent page" means to you. If you're just linking from one page to another, "parent" and "child" don't really make sense since page A links to page B and B links to A quite frequently.
    Assuming that you have to log in to access the site, it is likely that the two pages share the same middle tier application session. It is unlikely that the middle tier would hold the database session from the first request open waiting to see if the user eventually requested the second page. It is theoretically possible that you could code your middle tier this way but it is extremely unlikely that you would want to do so for a variety of reasons. So, when you say "would [the] session ... be changed", it is likely that the application session would be the same for both calls but that the database session would be different.
    Justin

  • To fetch recodrs from cursor selecting from temporary table

    Hi all
    in my form iam creating a temporary table dynamically . from this table cursor is
    fetching records.
    table is creaitng dynmaically so i dn't knw the colmn name so how i can take the rows to display
    i had wriiten like this
    declare
    CURSOR C1 IS SELECT * FROM TMPTBL;-- IS THE TEMPORYTABLE
    XREC C1%ROWTYPE;
    Begin
    OPEN C1;
         LOOP
         FETCH C1 INTO XREC;
         EXIT WHEN C1%NOTFOUND;
    TXT:=XREC.FIELDNAME??/??? HOW WE CAN SEPCIFY HERE
    end loop          
    end;
    HOW WE CAN SELECT XREC.(FIELDNAME) . ACTUALLY FIELD NAME IS NOT KNOWN
    Thanks and regards
    Vivek

    Acutally i have to export the rows from the views to a excel file.
    when i select a view from from that view contents i have to export to excel .
    for that when exporting am creating a temporay table with the contents of the selected view.
    And by fetching the rows from table i ahev to export it to excel by
    using DDE.POKE Statement
    Is there any other way to do this
    Thnks and regards

  • Problem with Temporary Table (Urgent)

    Hi all,
    Yesterday also i was facing da problem of gettin records from a global temporary table .. Today also i made a procedure in which i have to create a temporary table according to da select query ..and when i m printing da count(*) from tht table .. result is 0 tht means records r not inserting ..
    But if i m creatin it as a normal Create Table i m gettin da result..
    I want the table shud b created n records fetch by the query shud b inserted.. I have checked query is fetchin records..
    Sorri but still da same proble .. pls help me out
    PROCEDURE prn_trnASRGetStudentCertInfo(strIntakeSession          IN sisStudent.IntakeSession          %TYPE,      
                             strProgramCode          IN sisStudent.ProgramCode          %TYPE)
         AS
         intCount Number(3);
         SQLSTR     varchar2(100);     
         BEGIN
              EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE tmpStudentCert
                        AS
                        SELECT     sisEnrolment.EnrolmentID     As EnrolmentID,     
                                  sisEnrolment.StudentID          As StudentID,
                                  sisEnrolment.ProgramCode     As PrgCode,
                                  sisCourseEnrolled.CourseCode     As CourseCode,
                                  sisCourseEnrolled.Status     As Status,
                                  exmCCResult.Status           As exmStatus     
                        FROM          sisStudent
                        INNER JOIN sisEnrolment
                        ON
                             sisStudent.StudentID = sisEnrolment.StudentID
                        INNER JOIN sisCourseEnrolled
                        ON
                             sisEnrolment.EnrolmentID = sisCourseEnrolled.EnrolmentID
                        INNER JOIN exmCCResult
                        ON
                             sisCourseEnrolled.CourseCode =      exmCCResult.CourseCode
                        AND
                             sisCourseEnrolled.ProgramCode = exmCCResult.ProgramCode     
                        WHERE
                             UPPER(TRIM(sisStudent.IntakeSession)) = UPPER(TRIM('''||strIntakeSession||'''))
                        AND
                             UPPER(TRIM(sisStudent.ProgramCode)) = UPPER(TRIM('''||strProgramCode||'''))
                        AND
                             UPPER(TRIM(sisCourseEnrolled.Status)) <> TRIM(''D'')
                        AND
                             UPPER(TRIM(exmCCResult.Status)) = TRIM(''P'')';
              COMMIT;     
              SQLSTR := 'SELECT COUNT(*) FROM TMPSTUDENTCERT';
              EXECUTE IMMEDIATE SQLSTR INTO INTCOUNT;
              dbms_OUTPUT.PUT_LINE(INTCOUNT);
         END prn_trnASRGetStudentCertInfo;

    Hi there,
    You have had quite a few replies from the previous post and you should have learnt from that.
    Creating a procedure to do what you are trying to do is logically not sound.
    Firstly, a Global temporary table IS a database object which continous to exist like a normal table except that its data is not permanent. Therefore, there is no point in creating it dynamically in a procedure.
    Secondly, as I pointed out earlier, the data is temporary and it is gone once you issue a commit. A DDL like 'Create Table' will implicitly issue a commit after it has created the table - therefore all the data inserted as part of the Create Table statement will never be there.
    Hence, the subsequent SELECT COUNT(*) from the table will always return 0.
    Regards,
    John

  • Returning a ref cursor on a Global Temporary table

    I realize this is probably not feasible but I am manipulating data and storing it in a GTT and I wish to return that transformed data out as a ref cursor is this possible to do? I also dont want a static table because this is a heavily hit procedure and I do not want to have to keep track of which session is which data not to mention contention between them.
    I am using Oracle 10g on Windows server 2008

    You will be able to see the records in the refcursor in the same session
    Example
    SQL> create global temporary table X_GTT as select * from emp where 1=2;
    Table created.
    SQL> insert into x_GTT select * from emp ;
    14 rows created.
    SQL> var rf refcursor ;
    SQL> begin
      2    open :rf for select * from X_GTT ;
      3  end ;
    PL/SQL procedure successfully completed.
    SQL> print rf
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    99
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.SS

  • Using temporary tables with a ref. cursor

    I want to use a temporary table to populate certain data and then return a ref cursor fetching data from the temporary table.
    1. Will this approach work ?
    2. Do I need to drop the temporary table ? Can I drop the table as a last statement in the stored proc (remember a ref cursor based on this table is to be returned as a out parameter).
    Please help.

    1. Will this approach work ?Sort of, just like it is possible to dig a trench with a spoon. It can be done, but why can't you just write a select that returns the data without storing intermediate versions of your processing somewhere.
    2. Do I need to drop the temporary table ?No. and you shouldn't.
    Can I drop the table as a last statement in the stored proc
    (remember a ref cursor based on this table is to be returned as a out parameter).No.
    If you really need to use a temporary table, it should be created one time when the application is installed, and should never be created in code.

  • Creating temporary table in pl/sql block problem

    hello
    i have a problem in creating and using temporary table in pl/sql block
    please verify below block
    begin
    execute immediate 'create global temporary table alitemp1 (co_t varchar2(10),color varchar2(10))';
    insert into alitemp1 (co_t,color) values ('001','red');
    execute immediate 'DROP TABLE alitemp1';
    end;
    when i execute that block i will receive this error
    insert into alitemp1 (co_t,color) values ('001','red');
    ERROR at line 3:
    ORA-06550: line 3, column 14:
    PL/SQL: ORA-00942: table or view does not exist
    ORA-06550: line 3, column 2:
    PL/SQL: SQL Statement ignored
    i think it because that alitemp1 table don't create
    but two below block run fine
    begin
    execute immediate 'create global temporary table alitemp1 (co_t varchar2(10),color varchar2(10))';
    execute immediate 'DROP TABLE alitemp1';
    end;
    begin
    execute immediate 'create global temporary table alitemp1 (co_t varchar2(10),color varchar2(10))';
    end;
    select table_name from user_tables where table_name='ALITEMP1';
    TABLE_NAME
    ALITEMP1
    it means that problem is when the below line exists in block
    insert into alitemp1 (co_t,color) values ('001','red');
    if may please guide me

    In addition to the comments by Justin and 3360, you cannot do what you want the way you are doing it.
    All objects referred to in a PL/SQL block must exist at the time the block is compiled. In your case, since it is an anonomous block, that is run time. Since you are dynamically creating the temporary table you need to refer to it dynamically as well. More like:
    BEGIN
    EXECUTE IMMEDIATE 'create global temporary table alitemp1 (co_t varchar2(10),
                                                               color varchar2(10))';
    EXECUTE IMMEDIATE 'insert into alitemp1 (co_t,color) values (:b1,:b2)' USING '001', 'red';
    EXECUTE IMMEDIATE 'DROP TABLE alitemp1';
    END;However, don't do that it is a really bad idea. Just create the temporary table, if you really need it, once and use it in your processing.
    In most cases, things that SQL Server needs temporary tables for can be done easily in Oracle with a single SQL statement,
    John

  • Problem with temporary table in stored procedure

    Hi,
    I have to execute a stored procedure in java , where the stored procedure has refcursor as out parameter and within the procedure the refcursor out parameter is populated from a temporary table
    when iam trying to get the resultset in my program iam getting the oracle error: ora-08103 object is no longer in use.
    I think this is becos the temporary table object is not available to my program
    can any one please help me

    I don't understand this part.
    Your procedure has "argSchemaName" as input parameter. Why do you have hardcoded owner name here in the cursor?
    >>
    CURSOR csrEligTables IS
    SELECT
    object_name
    FROM
    all_objects
    WHERE
    Owner = 'HI0XXX001'
    AND
    >>
    The anonymous block that you are running also has same owner name.

  • Problem ! Calling report6 from forms6(run_product()) using global temporary table.

    Requirement :
    To generate stock movement report for certain selected items.
    Background :
    A Form is created with data block (tmp_item_master - a global temporary table)
    when_new_form_instance :
    inserting into tmp_item_master from item_master and then execute_query on tmp_item_master block.
    User selects certain items using check box provided.
    Now tmp_item_master is updated for ch_select_flag_yn = 'Y' for selected items
    and commit.
    Calling report from form(using run_product()).
    Now the main query in report, is joined with tmp_item_master where ch_select_flag_yn = 'Y'
    Here, we are unable to see the report for any item. As the global temporary table data is not visible in the report session.
    How to resolve this problem ?
    Note : global temporary table created with ON COMMIT PRESERVE ROWS
    Thanking you,
    From praful.
    null

    Hi,
    You are using 'ON Commit Delete Rows' . Instead of Use ' ON COMMIT PRESERVE ROWS'
    The ON COMMIT DELETE ROWS clause indicates that the data should be deleted at the end of the transaction.
    CREATE GLOBAL TEMPORARY TABLE my_temp_table (
    column1 NUMBER,
    column2 NUMBER
    ) ON COMMIT DELETE ROWS;
    In contrast, the ON COMMIT PRESERVE ROWS clause indicates that rows should be preserved until the end of the session.
    CREATE GLOBAL TEMPORARY TABLE my_temp_table (
    column1 NUMBER,
    column2 NUMBER
    ) ON COMMIT PRESERVE ROWS;
    Edited by: Mrucha on Nov 26, 2012 6:06 AM

  • Global temporary table problem ???

    I defined a temporary table which is used by my procedures. It was defined as 'on commit delete rows'. When I test those procedures manually, it works fine. But when the procedures are called in our application, I got 'ora-08103 object no longer exists'. (The temporary table is only used before commit the transanction in our applicaiton).
    After I changed the temporary table back to 'on commit preserve rows' and deleted all rows from it each time before using it, the problem was gone.
    Anyone knows why this happened? I have a before insert trigger on that temporary table.
    Thanks

    When I tested my app, I only had one user connected, I don't have DBMS_APPLICTION_INFO in my proc.
    I am not whether that trigger is the issue or not, I remember that trigger starts a seperate transanction, if that's true, the problem might be caused by trigger commiting the transanction. I need to double check this, I could be wrong.
    any other ideas?

  • Problem while creating index for temporary table...

    Hi,
    i have created index for a temporary table and this script should used by multiusers.So when second user connecting to it is giving index i mean object already exists.
    So what i need is when the second user connected the script should create one more index on temporary table.Will sql server provide any random way of creating indexes if the index exists already with that name??
    Thank You,

    Nope..
    SQL Server is cleaver enough to handel this situation.
    When you create a index or constraint on the Temp Table, eventhough the index name is duplicate it will allow.
    But it only possible on temp tables (prefixed with single #).
    To Test this,
    Open Two window,
    Execute the below window on the opened 2 window..
    create table #test
                id int
    Insert Into #test values(1);
    Insert Into #test values(2);
    Create clustered index testindex on #test(id)
    Now you wont get any error on any of the window. Rite?
    To fetch the created index details, execute the below code on any one of the window..
    select * from sysindexes where name like '%test%'
    Now you can see the 2 rows with same indexname but refereing with different table. Yes. all the temp tables (#) will be suffixed with unique number to avoid the object already found error while multiple users connects.
     

Maybe you are looking for

  • How to regenerate security certificates? CUCM 6.1.3

    Hi, Company has a call manager with 3 nodes on version 6.1.3: - NODO1: 10.102.224.254 - NODO2: 10.102.224.253 - NODO3: 10.102.239.20 From S.O. web can be seen that some certs are going to expire. We have received a warning via e-mail. And we have che

  • Calling a method in a different class?

    How do you call a method from a differnt class into the class you are working on?

  • 2nd gen shuffle blinks orange 3x then doesnt charge, isnt detected

    I have had and used my Ipod Shuffle for a couple months now and I go to plug my Ipod Shuffle into the USB dock and the Ipod light blinks orange three times and nothing happens after that. The Ipod is not detected by my computer or by Itunes. The Ipod

  • UI of MFC app blurred

    I am trying to port my MFC app from VS2010 to VS2013. The UI of the app built with VS2013 is blurred (and larger). With VS2010 it was ok. I tried the setting in VS „Manifest Tool – Input and output – DPI Awareness". I tried all 3 values (None, High D

  • Mac Book Pro Cant Install Maverick OS X

    Hi Guys, I tried installing the new Mavericks OS X into my mac book pro, it can not install with a pop up that the HDneeds repair. The options to repair disk is inactive, how can I go about it?