Temp table Question

In Oracle... can we use temp tables in procedures??? what would be the performance issue if I use a temp table in procedure?? After the procedure is run.. how can I assure that the temp table is deleted???

Hi,
You have miss interpreted Justin. He clearly replied all your questions which you have highlight in you 2nd post. You can use global temporary table in procedures but nto in manner in which you are using.
First of all your creation of temporary table inside a procedure is wrong. Create this table at SQL> prompt, as you create normal tables.
I don't see any requirment in which you have to create a table inside a procedure. The thing you are trying is not logical. Secondlly, you are firing a DDL statement inside a procedure so, you have to EXECUTE_IMMEDIATE.
Now, we come back to temporary table. You create temporary table on the SQL> prompt and use this table in your procedure as normal table. Perform any insert, update or delete on this table. Different user who perform DML on this table will have their own copy of data, means every user working on temporary table has it own copy of data.
Regarding the delete of data. You dont' have to worry bout this as oracle itself truncate data from temporary table when user finised with his session.
Any other doubt on temporary tables welcomed........

Similar Messages

  • Global Temp Table or PL/SQL Table

    I am trying to determine if this can be done only using PL/SQL table. If not, will the usage of the global temp table affects the performance.
    Here is the situation,
    I have a data block that is based on a stored procedure. This stored procedure will return table of records from different database tables with join conditions. Some of the fields within the table of records will not have data returned from database tables. They will be the fields displayed on the form and the data will be entered by user.
    For example:
    Records will look like:
    Id          (will be populated by procedure)
    Hist_avg     (will be populated by procedure)
    My_avg     (will be used as field on the form so that user can enter their own avg)
    Cheked     (will be populated by procedure)
    My questions are:
    1.     Is this doable in form using a data block based on PL/SQL table?
    2.     Will users be able to manipulate (update) the data that based on the PL/SQL table in the memory as they wish and invoke the procedure to update the underlying table when clicking on a button (Update Avg)?
    3.     What is the advantage of using PL/SQL table and global temp table from database and form point of views?
    Any info is appreciated.

    Hi there...
    Here is the Reference...
    http://asktom.oracle.com/pls/ask/f?p=4950:8:2939484874961025998::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:604830985638
    Best Regards...
    Muhammad Waseem Haroon

  • A better way than a global temp table to reuse a distinct select?

    I get the impression from other threads that global temp tables are frowned upon so I'm wondering if there is a better way to simplify what I need to do. I have some values scattered about a table with a relatively large number of records. I need to distinct them out and delete from 21 other tables where those values also occur. The values have a really low cardinality to the number of rows. Out of 500K+ rows there might be a dozen distinct values.
    I thought that rather than 21 cases of:
    DELETE FROM x1..21 WHERE value IN (SELECT DISTINCT value FROM Y)
    It would be better for performance to populate a global temp table with the distinct first:
    INSERT INTO gtt SELECT DISTINCT value FROM Y
    DELETE FROM x1..21 WHERE value IN (SELECT value FROM GTT)
    People asking questions about GTT's seem to get blasted so is this another case where there's a better way to do this? Should I just have the system bite the bullet on the DISTINCT 21 times? The big table truncates and reloads and needs to do so quickly so I was hoping not to have to index it and meddle with disable/rebuild index but if that's better than a temp table, I'll have to make do.
    As far as I understand WITH ... USING can't be used to delete from multiple tables or can it?

    Almost, but not quite, as efficient as using a temporary table would be to use a PL/SQL collection and FORALL statements and/or referencing the collection in your subsequent statements). Something like
    DECLARE
      TYPE value_nt IS TABLE OF y.value%type;
      l_values value_nt;
    BEGIN
      SELECT distinct value
        BULK COLLECT INTO l_values
        FROM y;
      FORALL i IN 1 .. l_values.count
        DELETE FROM x1
         WHERE value = l_values(i);
      FORALL i IN 1 .. l_values.count
        DELETE FROM x2
         WHERE value = l_values(i);
    END;or
    CREATE TYPE value_nt
      IS TABLE OF varchar2(100); -- Guessing at the type of y.value
    DECLARE
      l_values value_nt;
    BEGIN
      SELECT distinct value
        BULK COLLECT INTO l_values
        FROM y;
      DELETE FROM x1
       WHERE value = (SELECT /*+ cardinality(v 10) */ column_value from table( l_values ) v );
      DELETE FROM x2
       WHERE value = (SELECT /*+ cardinality(v 10) */ column_value from table( l_values ) v );
    END;Justin

  • Error while creating Global temp table

    Hi,
    I am very new to PL/SQL so please excuse my question. I have the below query . I have to get a count between the source table and various target tables. I am creating a global temp table to store the counts. I am getting the below error for my following query :
    Thanks for the help,
    Petronas
    ----Query----
    set serveroutput on
    Declare
    nm1 varchar2(200);
    nm2 varchar2(200);
    cnt1 number;
    cnt2 number;
    diff number;
    totdiff number;
    Begin
    nm1 := null;
    nm2:= null;
    cnt1:= 0;
    cnt2 := 0;
    diff := 0;
    totdiff := 0;
    create GLOBAL TEMPORARY TABLE diff ( name1 varchar(200), name2 varchar2(200), diff number);
    select count(*) into cnt1
    from users_staging;
    select count(*) into cnt2
    from PROD.users;
    nm1 := 'users_staging';
    nm2 := 'PROD.users';
    diff := cnt1 - cnt2;
    insert into diff values (nm1,nm2,diff);
    select count(*) into totdiff
    from diff
    where diff> 0 ;
    dbms_output.enable(10000);
    dbms_output.put_line('# of tables where difference is > 0 ' ||totdiff);
    end;
    Encountered the symbol "CREATE" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-identifier>
    <a bind variable> << close current delete fetch lock insert
    open rollback savepoint set sql execute commit forall merge
    pipe

    Hi,
    "CREATE GLOBAL TEPORARY TABLE ..." is not a PL/SQL command; it is a SQL command only.
    Create the table, using that statement, before running the PL/SQL block.
    You can issue SQL statements from within PL/SQL using the EXECUTE IMMEDIATE command, but this is rarely a good idea.
    I assume the PL/SQL code is meant to create the table and then populate it.
    You should split those into two separate pieces of code. You'll only want to create the table once, no matter how many times you use it. I assume you'll want to populate it the same way many times. Remember, the "TEMPORARY" in "GLOBAL TEMPORARY TABLE" refers to the data, not the table. When you end a transaction (or a session, depending on whther you want "ON COMMIT DELETE ROWS" or "ON COMMIT PRESERVE ROWS"), the data disappears, but the now-empty stays, ready to be populated for the next transaction (or session).
    Edited by: Frank Kulash on Aug 4, 2010 2:25 PM

  • How do I CREATE IF NOT EXISTS Temp table in PLSQL?

    hello, how do I CREATE IF NOT EXISTS Temp table in PLSQL? The following table is to be created in FIRST call inside a recursive function (which you'll see in QUESTION 2).
    QUESTION 1:
    CREATE GLOBAL TEMPORARY TABLE TmpHierarchyMap
                                  Id numeric(19,0) NOT NULL,
                                  ParentId numeric(19,0) NOT NULL,
                                  ChildId numeric(19,0) NOT NULL,
    ... more ...
                             ) on commit delete rows');
    QUESTION 2: How to return a temp table from a function?
    For example, this is how I'm doing it at the moment, using Nested Table.
    EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE TmpHierarchyMapObjType AS OBJECT
                   Id numeric(19,0) ,
                   ParentId numeric(19,0),
                   ChildId numeric(19,0),
    ... more ...
         EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE TmpHierarchyMapTableType AS TABLE OF TmpHierarchyMapObjType;';
    CREATE OR REPLACE FUNCTION fnGetParentsTable
    ObjectId number,
    ObjectClassifier varchar2
    RETURN TmpHierarchyMapTableType
    IS
    TmpHierarchyMap TmpHierarchyMapTableType := TmpHierarchyMapTableType();
    ThisTempId varchar2(32);
    CURSOR spGetParents_cursor IS
    SELECT
    Id,
    ParentId,
    ChildId,
    FROM TMP_HIERARCHYMAP
    WHERE TempId = ThisTempId;
    BEGIN
    SELECT sys_guid() INTO ThisTempId FROM dual;
    spRecursiveGetParents(ObjectId, ObjectClassifier, ThisTempId);
    FOR oMap in spGetParents_cursor LOOP
    TmpHierarchyMap.Extend();
    TmpHierarchyMap(TmpHierarchyMap.Count) := TmpHierarchyMapObjType( oMap.Id
    , oMap.ParentId
    , oMap.ChildId
    END LOOP;
    DELETE FROM TMP_HIERARCHYMAP WHERE TempId = ThisTempId;
    RETURN TmpHierarchyMap;
    END fnGetParentsTable;
    QUESTION 3: what does the word GLOBAL means? I read that temp table is visible only to a particular database connection/session and will be dropped automatically on termination of the session. i can only find this information in some forum discussion but failed to locate this in Oracle doc, can someone point me in right direction please?
    Many thanks!
    REF:
    http://stackoverflow.com/questions/221822/sybase-developer-asks-how-to-create-a-temporary-table-in-oracle
    http://www.oracle-base.com/articles/8i/TemporaryTables.php

    devvvy wrote:
    so if I CREATE GLOBAL TEMPORARY TABLE twice on second pass of my recursive function what then...?You don't create it inside your function.
    You create the GTT once on your database outside of the function and then just leave it there and use it.
    Tables should not be dynamically created and dropped.
    Only other database engines such as SQL Server use the concept of creating temporary tables during the execution of code. Oracle uses a "create once, use whenever" methodology.

  • Issue with Temp tables in SSIS 2012 with RetainSameConnection=true

    Hello,
    We have few packages written in 2008 and are being upgraded to 2012. Our package mostly uses temp tables during the process.  During initial migration, we faced issue with handling temp table in the OLE Db destination provider and found a solution for
    the same under 
    usage of Temp tables in SSIS 2012
    Most of our packages execute fine now. 
    we came across a different issue recently. For one of our package, which merges 3 feeds into a temp table and then executes a stored procedure for processing, the package fails intermittently.
    Below are properties of SSIS and its components, which you might be interested
    * Retainsameconnection for the OLE Db connection manager set to True
    * properties of OLEDB Destination 
    AccessMode : SQL Command
    CommandTimeOut : 0
    SQLCommand : Select * from #tmp
    * using SSIS 2012 and SQL OLEDB Native Provider 11 (Provider=SQLNCLI11.1)
    * one of the feed is 10MB
    During investigation using profiler, found that though I use RetainSameConnection, I often  could see that more than one SPId is used during the scope of SSIS execution and when ever this happens, package fails with below error message 
    An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.".
    An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E14 Description: "Invalid object name '#tmp'."
    Now, Why SSIS uses a different SPId during its execution when RetainSameconnection is set to True (note : I have only one OLEDB connection in that package)? 
    To simulate the issue, Instead of 10MB file, I used a 500KB file and execute the package twice and all went fine.
    Is it because of 10 MB file taking long time to process causing the time out of that OLEDB destionation forcing the SSIS to go for another connection? but remember, CommandTimeout is set to infinite(0) for that OLEDB destination. 
    Much appreciated your response. 

    Hey,
    I understand you used Retainsameconnection property true for all the OLEDB connections you used in the package if not make sure its for all the connection including file connection as well.
    Additionally, you can try to set Delayvalidation property to true for all the dataflows and control flows in the connection and try running the package for 10MB file.
    I hope this will fix the intermittent failure issue you are facing with SSIS.
    (Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker)
    Thanks,
    Atul Gaikwad.

  • Urgent!  Slow Result Set -- temp table slowing me??

    -- Running BC4J/JHeadstart/UIX
    Description:
    I have a uix page that calls a Servlet and passes a TABLE_NAME. The Servlet gets the TABLE_NAME and calls a class that extends oracle.jheadstart.persistence.bc4j.handler.DataSourceHandlerImpl to create a ViewObject and get the data we need. Once the ViewObject is passed back to the servlet, the servlet loops through the VIewObject and builds a report. See the problem below and the code at the bottom.
    Problem:
    I am running a query that returns approx 5000 records to my ViewObject. I then loop through the rows and construct a report. The view object will return the first 1085 records quickly, however, the following 4000 come back very slowly. I read online that BC4J creates temp tables to store large resultsets and then streams the data to the user as you need it. Is this our potential bottleneck?
    Questions:
    Is there a way to have it return all the rows? What can I do to speed this up?
    Code:
    --- Begin Servlet Snippet ---
    private ByteArrayOutputStream createReport(HttpServletRequest request)
    try{
    // PARM_REPORT = table name
    String reportName = request.getParameter(PARM_REPORT);
    System.out.println(">> calling getReport for " + reportName);
    RdmUserHandlerImpl handler = new RdmUserHandlerImpl();
    ViewObject vo = handler.getReportView2(reportName, request.getSession().getId());
    System.out.println(">> back from get report");
    // loop through report and print every 100
    while(vo.hasNext())
    curRow++;
    if (curRow % 100 == 0 )
    System.out.println(curRow + "");
    --- End Servlet Snippet ---
    --- Begin RdmUserHandlerImpl Snippet ---
    public ViewObject getReportView2(String tableName, Object sessionId) throws Exception {
    System.out.println("IN GET REPORT VIEW");
    ApplicationModule appMod = (ApplicationModule)getConnection("classpath...resource.MyUser", sessionId);
    // First see if we already created the view definition
    ViewObject vo = appMod.findViewObject(tableName);
    // If it was already created then refresh it, else lets try to create it
    if(vo != null) {
    System.out.println("found existing view");
    vo.reset();
    else {
    System.out.println("view not found, making new view");
    String query="SELECT * FROM " + tableName;
    System.out.println("QUERY = " + query);
    vo = appMod.createViewObjectFromQueryStmt(tableName, query);
    // max fetch returns -1
    System.out.println("MAX Fetch Size = " + vo.getMaxFetchSize());
    return vo;
    --- End RdmUserHandlerImpl Snippet ---
    Please reply asap! Deadline is coming fast!
    -Matt

    Matt,
    I think that you are right, the temporary tables created by BC4J are the reason for making it slow after a certain number of records. One of Steve Muench's articles includes the text:
    One of the most frequent performance-related questions we get on the Oracle Technet discussion forum is a question like, "After I query about a 1000 rows in a view object, my application gets very, very slow. What's happening?"
    It explains how you can turn off this feature, see the full article at http://www.oracle.com/technology/products/jdev/tips/muench/voperftips/index.html.
    The following article gives a lot of helpful information about the temporary tables:
    http://www.oracle.com/technology/products/jdev/htdocs/bc4j/bc4j_temp_tables.html
    The next article gives general tips for performance tuning of BC4J:
    http://www.oracle.com/technology/products/jdev/howtos/10g/adfbc_perf_and_tuning.html
    Hope this helps,
    Sandra Muller
    JHeadstart Team

  • BC4J temp tables & database role

    There are two essential BC4J temp tables (PCOLL_CONTROL, PS_TXN), along with others: http://www.oracle.com/technetwork/developer-tools/jdev/overview/bc4j-temp-tables-087270.html
    We have 'sysadmin' role associated in our Development DB, the passivation store table PS_TXN is populated as expected.
    However, in our production DB, we ONLY manually created the two above tables granted with Insert/Delete/Update/Select permissions (DBA will NOT agree to assign 'sysadmin' role), PS_TXN is not populated at all, which results in some session management issue in our application.
    So the question is: What is the proper database role to associate with for the temp tables to work properly (in our case, we use SQL server data source).
    Thank you,

    Mike, you need at least to add a sequence (PS_TXN_SEQ if I remember right) do you need to add a grant to create a sequence.
    Timo

  • MS SQL Server 2014: Error inserting into Temp table with index and identity field

    In this thread, I mentioned a problem with SQL Server 2014:
    SQL Server 2014: Bug with IDENTITY INSERT ON
    The question was answered, it is a bug. To keep you informed on this issue, I open this discussion.
    Problem:
    The code below works perfectly fine on MS SQL Server 2008 R2 and MS SQL Server 2012, but gives an error every second time the proc is executed on MS SQL Server 2014. If I do not define any index on the temp table, the problem disappears. Defining the index
    after the insert, does not help.
    SET NOCOUNT ON
    GO
    IF EXISTS (SELECT 1 FROM sys.procedures WHERE name = 'usp_Test') DROP PROC dbo.usp_Test;
    GO
    CREATE PROC dbo.usp_Test AS
    BEGIN
    SET NOCOUNT ON
    CREATE TABLE #Source(ID integer NOT NULL);
    INSERT INTO #Source VALUES (1), (2), (3);
    CREATE TABLE #Dest (ID integer IDENTITY(1,1) NOT NULL);
    CREATE INDEX #IDX_Dest ON #Dest (ID);
    PRINT 'Check if the insert might cause an identity crisis';
    SELECT 'Source' AS SourceTable, * FROM #Source;
    SELECT 'Destination' AS DestTable, * FROM #Dest;
    SET IDENTITY_INSERT #Dest ON;
    PRINT 'Do the insert';
    INSERT INTO #Dest (ID) SELECT ID FROM #Source;
    PRINT 'Insert ready';
    SET IDENTITY_INSERT #Dest OFF;
    SELECT * FROM #Dest;
    DROP TABLE #Source;
    DROP TABLE #Dest;
    END;
    GO
    PRINT 'First execution of the proc, everything OK';
    EXEC dbo.usp_Test;
    PRINT '';
    PRINT 'Second execution of the proc, the insert fails.';
    PRINT 'Removing the index #IDX_Dest causes the error to disappear.';
    EXEC dbo.usp_Test;
    GO
    DROP PROC dbo.usp_Test;
    GO

    There is some progress. Communication from a former Microsoft employee tells us this:
    Shivendra Vishal
    Engineer at Microsoft
    I am no longer with MS, and I do not have code access, however from the public symbols, I could make out following:
    sqlmin!SetidentI2I4+0x1f3:
    000007fe`f4d865d3 488b10 mov rdx,qword ptr [rax] ds:00000000`00000000=????????????????
    ExceptionAddress: 000007fef4d865d3 (sqlmin!SetidentI2I4+0x00000000000001f3)
    ExceptionCode: c0000005 (Access violation)
    ExceptionFlags: 00000000
    NumberParameters: 2
    Parameter[0]: 0000000000000000
    Parameter[1]: 0000000000000000
    Attempt to read from address 0000000000000000
    This is a read AV and from registers it is clear that we were trying to move the value of location pointed by qword of register rax which is not valid:
    rax=0000000000000000 rbx=0000000000000038 rcx=0000000000001030
    rdx=0000000000000006 rsi=00000001f55def98 rdi=00000000106fd070
    rip=000007fef4d865d3 rsp=00000000106fcf40 rbp=00000000106fcfe9
    r8=0000000000000000 r9=00000001f55def60 r10=00000001f55defa0
    r11=00000000106fcd20 r12=0000000000000000 r13=0000000000000002
    r14=00000001f49c3860 r15=00000001f58c0040
    iopl=0 nv up ei pl nz na po nc
    cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010206
    The stack is:
    # Child-SP RetAddr Call Site
    00 00000000`106fcf40 000007fe`f30c1437 sqlmin!SetidentI2I4+0x1f3
    01 00000000`106fd050 000007fe`f474e7ce sqlTsEs!CEsExec::GeneralEval4+0xe7
    02 00000000`106fd120 000007fe`f470e6ef sqlmin!CQScanUpdateNew::GetRow+0x43d
    03 00000000`106fd1d0 000007fe`f08ff517 sqlmin!CQueryScan::GetRow+0x81
    04 00000000`106fd200 000007fe`f091cebe sqllang!CXStmtQuery::ErsqExecuteQuery+0x36d
    05 00000000`106fd390 000007fe`f091ccb9 sqllang!CXStmtDML::XretDMLExecute+0x2ee
    06 00000000`106fd480 000007fe`f08fa058 sqllang!CXStmtDML::XretExecute+0xad
    07 00000000`106fd4b0 000007fe`f08fb66b sqllang!CMsqlExecContext::ExecuteStmts<1,1>+0x427
    08 00000000`106fd5f0 000007fe`f08fac2e sqllang!CMsqlExecContext::FExecute+0xa33
    09 00000000`106fd7e0 000007fe`f152cfaa sqllang!CSQLSource::Execute+0x86c
    0a 00000000`106fd9b0 000007fe`f152c9e8 sqllang!CStmtExecProc::XretLocalExec+0x25a
    0b 00000000`106fda30 000007fe`f152a1d8 sqllang!CStmtExecProc::XretExecExecute+0x4e8
    0c 00000000`106fe1e0 000007fe`f08fa058 sqllang!CXStmtExecProc::XretExecute+0x38
    0d 00000000`106fe220 000007fe`f08fb66b sqllang!CMsqlExecContext::ExecuteStmts<1,1>+0x427
    0e 00000000`106fe360 000007fe`f08fac2e sqllang!CMsqlExecContext::FExecute+0xa33
    0f 00000000`106fe550 000007fe`f0902267 sqllang!CSQLSource::Execute+0x86c
    10 00000000`106fe720 000007fe`f0909087 sqllang!process_request+0xa57
    11 00000000`106feee0 000007fe`f2bf49d0 sqllang!process_commands+0x4a3
    12 00000000`106ff200 000007fe`f2bf47b4 sqldk!SOS_Task::Param::Execute+0x21e
    13 00000000`106ff800 000007fe`f2bf45b6 sqldk!SOS_Scheduler::RunTask+0xa8
    14 00000000`106ff870 000007fe`f2c136ff sqldk!SOS_Scheduler::ProcessTasks+0x279
    15 00000000`106ff8f0 000007fe`f2c138f0 sqldk!SchedulerManager::WorkerEntryPoint+0x24c
    16 00000000`106ff990 000007fe`f2c13246 sqldk!SystemThread::RunWorker+0x8f
    17 00000000`106ff9c0 000007fe`f2c13558 sqldk!SystemThreadDispatcher::ProcessWorker+0x3ab
    18 00000000`106ffa70 00000000`775d59ed sqldk!SchedulerManager::ThreadEntryPoint+0x226
    19 00000000`106ffb10 00000000`7780c541 kernel32!BaseThreadInitThunk+0xd
    1a 00000000`106ffb40 00000000`00000000 ntdll!RtlUserThreadStart+0x21
    Unassembling the function:
    000007fe`f4d8658e 4c8b10 mov r10,qword ptr [rax]
    000007fe`f4d86591 4533e4 xor r12d,r12d
    000007fe`f4d86594 410fb7d5 movzx edx,r13w
    000007fe`f4d86598 4533c9 xor r9d,r9d
    000007fe`f4d8659b 4533c0 xor r8d,r8d
    000007fe`f4d8659e 488bc8 mov rcx,rax
    000007fe`f4d865a1 4489642420 mov dword ptr [rsp+20h],r12d
    000007fe`f4d865a6 41ff5230 call qword ptr [r10+30h]
    000007fe`f4d865aa 8b5597 mov edx,dword ptr [rbp-69h]
    000007fe`f4d865ad 4c8b10 mov r10,qword ptr [rax]
    000007fe`f4d865b0 4489642438 mov dword ptr [rsp+38h],r12d
    000007fe`f4d865b5 4489642430 mov dword ptr [rsp+30h],r12d
    000007fe`f4d865ba 458d442401 lea r8d,[r12+1]
    000007fe`f4d865bf 4533c9 xor r9d,r9d
    000007fe`f4d865c2 488bc8 mov rcx,rax
    000007fe`f4d865c5 c644242801 mov byte ptr [rsp+28h],1
    000007fe`f4d865ca 4488642420 mov byte ptr [rsp+20h],r12b
    000007fe`f4d865cf 41ff5250 call qword ptr [r10+50h]
    000007fe`f4d865d3 488b10 mov rdx,qword ptr [rax] <=================== AV happened over here
    000007fe`f4d865d6 488bc8 mov rcx,rax
    000007fe`f4d865d9 4c8bf0 mov r14,rax
    000007fe`f4d865dc ff5268 call qword ptr [rdx+68h]
    000007fe`f4d865df 488d55e7 lea rdx,[rbp-19h]
    000007fe`f4d865e3 4c8b00 mov r8,qword ptr [rax]
    000007fe`f4d865e6 488bc8 mov rcx,rax
    000007fe`f4d865e9 41ff5010 call qword ptr [r8+10h]
    000007fe`f4d865ed f6450a04 test byte ptr [rbp+0Ah],4
    I remember few issues with scan2ident function, I am not sure if they have fixed it however it appears that this is intoduced to SQL 2014 and we need help from MS to get this resolved as it needs code analysis.
    It is not getting simulated for other versions of SQL apart from SQL 2014.
    Also to add, interestingly, the value of rax is not visibly changed and it was successfully passed on to rcx, which has a valid value, so something should have changed the value of rax inside call to function using call qword ptr [r10+50h], and looking at this
    it appears that it might be a list of functions and we are going at particular offset [50h]. So, bottom line is that the call to function qword ptr [r10+50h], should be changing something in rax, and debugging/analyzing this code might give us some more idea.

  • A temp table in a stored procedure , set a value to varchar(MAX)

    Hi ,,
    In stored procedure there is  a temp table and set a value to varchar(MAX) . What exactly is the different between setting it to varchar (MAX) instead of  varchar(n)
    Thank You
    Jeevan Vinay

    Vinay,
    Spend some time online to read and search about your problem before blindly posting it on forum, if you would have done that you could have found out eaisly below two links which will explain you in deep
    http://stackoverflow.com/questions/3682821/difference-between-varchar500-vs-varcharmax-in-sql-server
    http://sqlhints.com/2013/03/10/difference-between-sql-server-varchar-and-varcharmax-data-type/
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • Global temp tables for GeoRaster mosaicing

    Hi,
    Although this question involves the GeoRaster capability contained in the Spatial package, it has more to do with global temp tables, so it's in this forum group.
    The mosaicing function requires all the individual images (there is an image in each record) to be in their own table before they can be mosaiced, as there is no way to stipulate only certain images in a table should be used.
    So the best idea I've had so far is to use a global temp table where the images I need can be selected and put in the temp table - then mosaiced. It is important that the temp table contain only the images needed for a given mosaic. However, I will be doing the mosaic operation many times in a given session (possibly even more than 1 mosaic at the same time) and am worried that there will be old or unrelated records in the temp table.
    Does this mean I have to make a new session every time I need to mosaic an image? This doesn't sound very efficient. Can I have just one session but have a "new" temp table each time?
    Thanks,
    MH

    I have very limited experience with Spatial, and have never done anything like a mosaic
    But regarding Global Temp... If you want to make sure the GTT is empty every time, just end your transaction (commit or rollback). This will remove all data from the GTT (if you had it made with ON COMMIT DELETE ROWS - the default)

  • Create temp table using EXECUTE IMMEDIATE

    Is there any performance issue in creating globally temp table
    using EXECUTE IMMEDIATE or creating globally temp table from
    SQL PLUS.
    Any response will be greatly appreciated.
    null

    Anish,
    Creating tables is likely to be an expensive operation.
    Performance issues can only be considered in comparison to
    alternatives.
    Alternatives include: PLSQL tables, cursors and/or recoding so
    that tmp tables are not required. (One of our consultants reckons
    that sqlserver temp tables are usually used to get around
    limitations in sqlserver, ie slightly more complicated sql
    statements could be used instead of simpler sql and temporary
    tables).
    I would think creating the temp table once during sqlplus would
    be cheaper than creating and deleting it repeatedly at run time.
    Note that EXECUTE IMMEDIATE may do an implicit commit (dbms_sql
    certainly does). This may be got over my using the PRAGMA
    AUTONOMOUS_TRANSACTION; direction which places a
    procedure/function in a seperate transaction.
    Turloch
    P.S. We have some difficulty in getting information back from the
    field/customer sites. If you have questions and answers that are
    likely to be useful to other Oracle Migration Workbench
    users, and migrators in general, please send them in for possible
    inclusion in our Frequently Asked Question list.
    Oracle Migration Workbench Team
    Anish (guest) wrote:
    : Is there any performance issue in creating globally temp table
    : using EXECUTE IMMEDIATE or creating globally temp table from
    : SQL PLUS.
    : Any response will be greatly appreciated.
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Data storage in temp tables

    Question 1: I have created a global temporary table tt_groups(grp_ids number) on commit preserve rows; and I was wondering - if I have multiple users accessing this temp table at the same time, do I need to differenciate between the users, or will Oracle put a userid on them?
    Question 2: I am attempting to enter data into these temp tables within a function that will actually use the data. This function contains and returns a cursor. So far, I have been having great difficulties with this - to the point that I am ready to write an addition function just to store the data in the temp table. Does any one have any suggestions? Here is a sample of my code in case that would help. btw - str2tbl is a home grown conversion tool that parses a string and puts the data into rows of number. We have used it in many functions and so far don't have any issues associated with it.
    in_groupid IN VARCHAR2
    IS
    BEGIN
    INSERT INTO tt_groups(grp_ids)
    VALUES (
    SELECT Column_Value
    FROM THE (
    select cast(STR2TBL(in_groupid) as mytableType)
    from dual
    COMMIT;
    END;
    I am new to the whole sp/function coding, so any advice would be appreciated.
    Thanks,
    Susan

    Thanks, Justin, for your reply.
    I am pleased to hear that the temp table is session-specific.
    I attempted to update my statement to match what you suggested, but I am still getting "invalid" whenever I try to compile the function through schema mgr. Do you see anything that I might be missing? I incorporated the BEGIN; COMMIT; and END;, but is there something else that I am supposed to have? I downloaded a couple of Oracle handbooks and I have one book, Oracle8i - the complete reference, (we are using 9i) that I am referring to all the time, but I can't seem to get it to work! Here is more of my code:
    in_groupid IN VARCHAR2
    RETURN Types.ref_cursor
    AS
         resource_cursor types.ref_cursor;
    BEGIN
         OPEN resource_cursor FOR
    SELECT DISTINCT
    CATEGORY.CATID, SUBCATEGORY.SUBCATID
    FROM SUBCATEGORY, CATSUBCAT, CATEGORY, SUBRES
    WHERE SUBCATEGORY.SUBCATID = CATSUBCAT.SUBCATID AND
    CATSUBCAT.CATID = CATEGORY.CATID AND
    (CATSUBCAT.GROUPID IN (select grp_ids from tt_groups)) AND
    (SUBRES.GROUPID IN (select grp_ids from tt_groups))
    I want to insert this code into the function above:
    INSERT INTO dtra_tt_groups(grp_ids)
    SELECT Column_Value
    FROM THE (
    select cast(STR2TBL(in_groupid) as mytableType)
    from dual
    COMMIT;
    Where would I insert this statement?
    Thanks,
    Susan

  • 8i temp tables

    We are converting from Informix 7 to Oracle 8i. We are trying to emulate the Informix version as much as possible, using sql create global temporary table for a large number of temp tables in the app. Since the created table name spans sessions for a userid (even though the data doesn't), we are thinking of adding the sessionid to the name:
    sql create global temporary table <tablename>:(sessionid).
    Is this a good solution, has anyone used this?

    I've seen this technique before (common code used by two different databases), and my advice is DON'T USE IT!
    You will end up with code that performs poorly on both platforms, and whatever time is saved from only writing code once is easily lost again in trying to devise "platform neutral" techniques.
    If necessary, use a language that's independent of the specific database in use, then call stored procedures to perform selects, inserts, updates and deletes as necessary. These stored procedures should provide a common external interface, but should utilise whatever methods are appropriate for the DB in question to actually perform the work.
    For example, write a Java class to perform the database access against Informix, and one that does likewise for Oracle. Your main application can than instantiate the appropriate class for the DB in question without worrying HOW the work is done. Providing the two classes each provide a common interface, your application is insulated from the detailed differences between Oracle and Informix.

  • Drop temp tables

    how to drop temp tables if i created with same name in different sessions 
    create table #temp(id int)
    (with same in different sessions)

    In addition to Olaf's, if you create temp table in two different sessions, you will find the 2 #test in the TempDB.sys.tables.
    CREATE TABLE #test (id int);
    Either the different object_ids or the "same" names indicate they are
    different temp tables. The same named local temp tables created in different sessions are traced with a 12 suffix in the tempdb.sys.tables. That's why when creating temp tables, maximum length can be of 116 characters only, while creating a
    table, the maximum is 128.
    The fragment referenced from the BOL
    You can create local and global temporary tables. Local temporary tables are visible only in the current session; global temporary tables are visible to all sessions.
    All local temporary tables are dropped automatically at the end of the current session.
    You can read more from the below link.
    https://technet.microsoft.com/en-us/library/aa258255(v=sql.80).aspx
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for

  • Screensaver does not start automatically after installing ML

    I can activate using hot corners but I've tried multiple delay times and it will not start.  Must be missing something simple.  Not having any issues accessing the same photos/images as on Lion, BTW

  • No video is getting to My older 720P TV

    I just bought a AppleTV. Hooked it up to my TV (LG RU-44SZ51D DLP) using a HDMI to DVI cable and started setup. I was able to see the interface to enter my Apple ID and adjust settings. It asked if it could do a system upgrade and I said yes. When it

  • Need help embedding a mp3 player swf with xml playlist

    Im a noob to Flash (started tuesday, haha) and so far everything is coming along just fine, but i need to put music in the swf. I have a button set up that slides a swf mp3 player in from the side but i dont know how to make the playlist work with it

  • How do I tell if my operating system is on my SSD or HD?

    I just bought a 27" iMac with a 1TB HD + 256 SSD.  I appears that most of my stuff is on my SSD but there is some "other" stuff on my HD according to my "About This Mac > Storage".  How do I manage this?  I want my operating system, applications, and

  • How to test an Enterprise service?

    Hi Experts, Iam very new to this Enterprise Service. I need to test an Enterprise service from my ABAP system. What is the Pre requistics to test the Enterprise service? What is the necessity of WS Navigator ,SOAPUI and SOA Manager? Is  SOAP UI need