With temp table statement

what is the impact of using this with statement. e.g.
with
view_temp as
(select * from view_table)
select * from view_temp....
it cause long running queries..it says below:
NSERT /*+ APPEND BYPASS_RECURSIVE_CHECK */ INTO "SYS"."SYS_TEMP_0FD9D6607_25EEFA14" SELECT /*+ */ "view_table"
Anyone could explain?

Subquery factoring ("with table_name as (...)") allows the optimizer to choose to put the factored query into a system temp table if it feels that that would be best.
see: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#i2077142
If you think the optimizer shouldn't be sorting the results in a temp table to use elsewhere, you should look at why the optimizer thinks that it's the best option. Somewhere your stats are not up to date, or your query and/or view need tuning... If the latter, and you need help in tuning your statement(s), then read this first: HOW TO: Post a SQL statement tuning request - template posting
Edited by: Boneist on 30-Jun-2009 11:51

Similar Messages

  • 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.

  • A Select statement with Appending table statement in it.

    Hi,
      How can I use a select statement with a <Appening table> statement in it.
    SELECT DISTINCT <field Name>
                    FROM <DB table name>
                    APPENDING TABLE <itab>
                    WHERE <fieldname> EQ <Itab1-fieldname>
                      AND <fieldname> EQ <itab2-fieldname>.
    Can I use the above select statement.If I'm using this...how this works?
    Regards
    Dharmaraju

    Hi, Dharma Raju Kondeti.
    I found this in the SAP online help, hope this can help you.
    Specifying Internal Tables
    When you read several lines of a database table, you can place them in an internal table. To do this, use the following in the INTO clause:
    SELECT ... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE <itab>
                              [PACKAGE SIZE <n>] ...
    The same applies to the line type of <itab>, the way in which the data for a line of the database table are assigned to a table line, and the CORRESPONDING FIELDS addition as for flat work areas (see above).
    The internal table is filled with all of the lines of the selection. When you use INTO, all existing lines in the table are deleted. When you use APPENDING; the new lines are added to the existing internal table <itab>. With APPENDING, the system adds the lines to the internal table appropriately for the table type. Fields in the internal table not affected by the selection are filled with initial values.
    If you use the PACKAGE SIZE addition, the lines of the selection are not written into the internal table at once, but in packets. You can define packets of <n> lines that are written one after the other into the internal table. If you use INTO, each packet replaces the preceding one. If you use APPENDING, the packets are inserted one after the other. This is only possible in a loop that ends with ENDSELECT. Outside the SELECT loop, the contents of the internal table are undetermined. You must process the selected lines within the loop.
    Regards,
    feng.
    Edited by: feng zhang on Feb 21, 2008 10:20 AM

  • Stored procedure with temp table creation inside and using it

    I want to create a temp table inside a stred procedure and make use of it . I want perform some delete statements based on select statemets .An I want to drop the table at the end .
    When I tried to create a table inside the stored procedure using exxecute immediate statement ,.
    sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure';
         EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from woc_pattern_structure' ;
    Then my select statements that contain this table do not identify the table name.
    I got compilor error when I use it in hte stored procedure in the select statement .Then I did like this-
    WHENEVER SQLERROR CONTINUE
    DROP TABLE pattern_str_temp;
    CREATE TABLE pattern_str_temp AS SELECT * FROM pattern_structure ;
    COMMIT;
    CREATE OR REPLACE PACKAGE BODY Woc_Delete_Model_Data
    AS
    NAME: Woc_Delete_Model_Data
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 11/01/2008 gtutika 1. Deletes given Product Model
    PROCEDURE deleteCategory(p_product_model IN varchar2,
                   p_request_status OUT VARCHAR2,
                   p_err_mesg OUT VARCHAR2
    IS
    l_category VARCHAR2(200);
    l_count NUMBER;
    CURSOR getAttribute IS
         SELECT Category_Name
         FROM
    Woc_Attribute_Category
    WHERE Attribute_Name in
    (SELECT Child_Name FROM pattern_structure
    WHERE Child_Type = 'Attribute' and product_Model_Name = p_product_model)
    FOR UPDATE;
    BEGIN
         DBMS_OUTPUT.ENABLE(1000000);
         --dbms_output.put_line('START-Inside DeleteCategory Procedure .........');
         --sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure';
         --EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure' ;
         OPEN getAttribute ;
    LOOP
         FETCH getAttribute INTO l_category ;
         EXIT WHEN getAttribute%NOTFOUND;
         l_count := Is_Category_Used(p_product_model , l_category);
    IF (l_count=0) THEN
         DELETE FROM WOC_ATTRIBUTE_CATEGORY where CATEGORY_NAME = l_category;
         DELETE from woc_item_category
         where CATEGORY_NAME = l_category;
         DELETE FROM WOC_CATEGORY WHERE CATEGORY_NAME = l_category;
    END IF;
         END LOOP;
         --(getAttribute%ROWCOUNT);
         CLOSE getAttribute;
         --dbms_output.put_line('END-Inside DeleteCategory Procedure .........');
    EXCEPTION
         WHEN OTHERS THEN
         dbms_output.put_line(SQLERRM);
              p_err_mesg := 'ERROR IN CUSOR';
              --dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    FUNCTION Is_Category_Used(p_product_model IN varchar2 , p_category IN Varchar2)
         RETURN NUMBER IS
         l_count NUMBER;
         l_attribute VARCHAR2(40);
         l_pattern varchar2(30);
         CURSOR getAttribute IS
         SELECT attribute_Name from
         WOC_ATTRIBUTE_CATEGORY WHERE category_name = p_category and Attribute_Name in
         (Select Child_Name from pattern_str_temp
         where child_type = 'Attribute' and product_Model_Name = p_product_model);
    BEGIN
    DBMS_OUTPUT.ENABLE(1000000);
         SELECT count(*) into l_count from
         WOC_ATTRIBUTE_CATEGORY WHERE category_name = p_category and Attribute_Name in
         (Select Child_Name from pattern_str_temp
    where child_type = 'Attribute' and product_Model_Name <> p_product_model);
         OPEN getAttribute;
    LOOP
         FETCH getAttribute INTO l_attribute;
         EXIT WHEN getAttribute%NOTFOUND;
         DELETE FROM pattern_str_temp WHERE Product_Model_Name=p_product_model
         and child_type = 'Attribute' and child_Name= l_attribute;
         END LOOP;
         CLOSE getAttribute;
         RETURN l_count;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(SQLERRM);
              --dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    PROCEDURE delete_batch_woc_model(p_product_model IN VARCHAR2,p_flag IN VARCHAR2,
    p_err_mesg OUT VARCHAR2)
         IS
         p_request_status VARCHAR2(30);
    BEGIN
         deleteCategory(p_product_model,p_request_status ,p_err_mesg );
    EXCEPTION WHEN OTHERS THEN
         dbms_output.put_line(SQLERRM);
              p_err_mesg := 'ERROR IN CUSOR';
              dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    END Woc_Delete_Model_Data;
    --drop table pattern_str_temp ;
    SHOW ERRORS;
    But once the data is deleted , the data in the temp table is deleted when I load the data and try to delete it agian since I have no data in temp table ,the data is not deleted .So I need to create the temp table every time the stored procedure is called ,delete accordingly and drop the table at the end .
    Please suggest how to do it.
    Thanks.

    I'm not sure I understand what you're attempting to do...
    What is the benefit of a temporary table that stores the same set of data that is in the master table? Why not just
    DELETE FROM child_table1
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM child_table2
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM child_table30
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM master_table
    WHERE some_condition;or
    FOR x IN (SELECT * FROM master_table WHERE some_condition)
    LOOP
      DELETE FROM child_table1 WHERE foreign_key = x.primary_key;
      DELETE FROM child_table2 WHERE foreign_key = x.primary_key;
      DELETE FROM child_table30 WHERE foreign_key = x.primary_key;
      DELETE FROM master_table WHERE primary_key = x.primary_key;
    END LOOP;Justin

  • Report with temp table

    Hi all,
    I need your suggestions.
    Have a need to build a report based on multiple queries and some updates. ( the updates are temporary, it will not update the source ). I would like to put data into a temporary table that is good for the log on session only then build the report based on this temporary table. Can BIP handle this ? I am open to any ideas. by the way report will be called from APEX side.
    oralce 10G, apex v4
    thx in advance.
    tai

    I set the data parameter at the report level as a DateTime type. It is defaulted to today()
    Only dataset1 uses the date parameter, dataset 2 doesn't.
    The query uses
    WHERE tdate =  ISNULL(@T_Date, CONVERT(VARCHAR(8), GETDATE(), 1))
    If I get rid of Dataset2, then the report is OK, so Dataset1 is able to read the date. But if Dataset2 which uses the temp table is added, then I get this error
             An error occured during local report processing
             An error occured during report processing
    Query execution failed for dataset Dataset2
    Invalid object name #temptable

  • Ssis sql command how to make it working with temp table #check , does not recognize though i created separate above data flow task a temp table through execute sql task.

    CREATE TABLE #check(
    reseller_account_id bigint NOT NULL PRIMARY KEY
    ,customer_id int NOT NULL
    INSERT INTO #check(reseller_account_id, customer_id)
    SELECT reseller_account_id, customer_id
    FROM ods.derived.postal_accounts pa
    JOIN ods.derived.bridge_accounts ba
    ON pa.bridge_id = ba.bridge_id
    AND pa.primary_multi_user_account_flag = 1
    WHERE promotion_code LIKE 'England-[01234]'
    AND reseller_account_id > 0;
    SELECT [reseller_id]
    ,c.reseller_account_id
    ,t.[postage_id]
    ,t.[customer_id]
    ,t.[mail_class_id]
    ,[mail_class_name]
    ,[mail_type_id]
    ,[mail_type_description]
    ,[org_zip_code]
    ,[dest_zip_code]
    ,[zone]
    ,t.[confirmation_number]
    ,[weight_category]
    ,[usps_postage_amount]
    ,[reseller_postage_amount]
    ,[cubic_pricing_flag]
    ,[destination_address]
    ,pe.recipient_address
    FROM ods.derived.v_reseller_prints_for_export t(NOLOCK)
    JOIN check_test c
    ON c.customer_id=t.customer_id
    JOIN ods.swsim.prints s(NOLOCK)
    ON t.postage_id=s.postage_id
    JOIN ods.postal.prints_extension pe(NOLOCK)
    on pe.postage_id=s.postage_id
    where t.customer_id IN (Select customer_id from #check)

    Hi Mark Subedi,
    In addtion to the above posts.
    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

  • Getting an error message while trying to use a ZTABLE with TABLES statement

    Hi All,
    I wanted to use a ZTable with the TABLES statement, but it is throwing an error saying " Ztable must be a flat structure. you cannot use internal tables, strings, references or structures as components."
    What might be the reason for this error??
    Thanks in advance.

    This Ztable, is this a transparent table (structure) or is it a table type?
    In case of table type, you should use USING or CHANGING parameter.
    Might be better to paste part of your code here, and do not forget to tell how this Ztable is defined (Data dictionary or even local type).

  • Best options to use in Temp Table

    Hello,
    I was just trying to figure out the best options we can choose with when we come across a scenario where we need to use a  Temp Table/Table Variable/Create
    a Temp Table on the fly.
    However, I could not see any big difference in using those options. As per my understanding using a table variable is more convenient if the query logic is
    small and the result set also will be comparatively small.Creating a temp table is also an easy option but it takes much time and we can not create any indexes on it. I am working on a query optimization task where in plenty of temp tables are used
    and the query takes more than five minutes to execute. We have created few indexes and all in few tables and reduced the query execution time up to 2 mnts.Can anyone give me more suggestions on it. I have gone through various articles about it and came to
    know that there is no one solution for this and I am aware of the basic criteria like  use Set No count on, Order the table in which the indexes are created, Do not use Select * instead use only columns which are really required, Create Indexes
    and all. Other than these I am stuck with the usage of temp tables. There are some limitations where I can convert all the Temp table logic to CTE (I am not saying its not possible, I really dont have time to spend for the conversion). Any suggestions are
    welcome.
    Actual Query
    select Code,dbo.GetTranslatedText(Name,'en-US')
    as Name from ProductionResponse.ProductionResponse
    00.00.02
    5225 rows
    With Table Variable
    DECLARE  @General
    TABLE(Code
    NVarchar(Max),Name
    NVarchar(Max)
    INSERT
    INTO @General
    select Code,dbo.GetTranslatedText(Name,'en-US')
    AS Name  from ProductionResponse.ProductionResponse
    select
    * from @General
    00.00.03
    5225 rows
    With an Identity Column
    DECLARE  @General
    TABLE(Id
    INT IDENTITY(1,1)
    ,Code NVarchar(Max),Name
    NVarchar(Max)
    INSERT
    INTO @General
    select Code,dbo.GetTranslatedText(Name,'en-US')
    AS Number  from ProductionResponse.ProductionResponse
    select
    * from @General
    00.00.04
    5225 rows
    With Temp Table:
    CREATE
    TABLE #General (Id
    INT IDENTITY(1,1)
    PRIMARY KEY,Code
    NVarchar(Max),Name
    NVarchar(Max)
    INSERT
    INTO #General
    select Code,dbo.GetTranslatedText(Name,'en-US')
    as Name from ProductionResponse.ProductionResponse
    select
    * from #General
    DROP
    TABLE #General
    00.00.04
    5225 rows
    With Temp Table on the Fly
    SELECT G.Code,G.Name
    INTO #General  
    FROM
    select Code,dbo.GetTranslatedText(Name,'en-US')
    as Name from ProductionResponse.ProductionResponse
    )G
    select
    * from #General
    00.00.04
    5225 rows

    >> I was just trying to figure out the best options we can choose with when we come across a scenario where we need to use a Temp Table/Table Variable/Create a Temp Table on the fly. <<
    Actually, we want to avoid all of those things in a declarative/functional language. The goal is to write the solution in a single statement. What you are doing is mimicking a scratch tape in a 1950's tape file system. 
    Another non-declarative technique is to use UDFs, to mimic 1950's procedural code or OO style methods. Your sample code is full of COBOL-isms! In RDBMS we follow ISO-11179 rules, so we have “<something in particular>_code” rather than just “code” like
    a field within a COBOL record. The hierarchical record structure provides context, but in RDBMS, data elements are global.  Or better, they are universal names. 
    >> I am aware of the basic criteria like use SET NO COUNT ON, Order the table in which the indexes are created, Do not use SELECT * instead use only columns which are really required, CREATE INDEXes and all.<<
    All good, but you missed others. Never use the same name for a data element (scalars) and a table (sets). Think about what things like “ProductionResponse.production_response” means. A set with one element is a bit weird, but that is what you said. Also, what
    is this response? A code? A count? It lacks what we call an attribute property. 
    This was one of the flaws we inherited when ANSI standardized SQL and we should have fixed it. Oh well, too late now. 
    Never use NVARCHAR(MAX). Why do you need to put all of the Soto Zen sutras in Chinese Unicode? When you use over-sized data elements, you eventually get garbage data. 
    >> Other than these I am stuck with the usage of temp tables. There are some limitations where I can convert all the Temp table logic to CTE (I am not saying its not possible, I really do not have time to spend for the conversion). Any suggestions are
    welcome.<<
    Yes! This is how we do declarative/functional programming! Make the effort, so the optimizer can work, so you can use parallelism and so you can port your code out of T-SQL dialect. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Usage of Temp tables in SSIS 2012

    Hello,
    We have many SSIS packages (2008 R2) which imports data to a temp table and process it from there. 
    We are upgrading to SQL server 2012 and facing the issue with temp table as working table and our ssis packages fail in 2012. While investigating found that SQL Server 2012 deprecates FMTONLY option
    and instead uses
    sp_describe_first_result_set , which does not support using of temp tables as import table.  SSIS works fine in our workstations but not in the DEV box.  With SQL 2012, I can execute from my workstation, which has (11.0.2100.60) where as DEV server
    has SQL Server version 11.0.3000.0 
    Also when I ran profile with that of the DEV box, it gives two different statements 
    from workstation (11.0.2100.60)
    CREATE TABLE #temp (
    Id varchar(255) NULL,
    Name varchar(255) NULL )
    go
    declare @p1 int
    set @p1=NULL
    declare @p3 int
    set @p3=229378
    declare @p4 int
    set @p4=294916
    declare @p5 int
    set @p5=NULL
    exec sp_cursoropen @p1 output,N'select * from #temp',@p3 output,@p4 output,@p5 output
    select @p1, @p3, @p4, @p5
    go
    it works fine
    But with the DEV server (version 11.0.3000.0), it executes the below sql and it fails to get the meta data
    CREATE TABLE #temp (
    Id varchar(255) NULL,
    Name varchar(255) NULL )
    exec [sys].sp_describe_first_result_set N'select * from [dbo].[#temp]'
    On checking the assembly difference between the versions, I could only see Microsoft.SqlServer.ManagedDTS.dll being 11.0.3000.0, which I replace by 11.0.2100.60 version. but still getting the same result. 
    The other different I found is with ,Net framework libraries.
    Could you advise whats the assembly causing this issue between our workstation and DEV server  i.e 11.0.2100.60 and 11.0.3000.0 
    Many thanks

    Scripts are taken from profiler.
    The error message is 
    The metadata could not be determined because statement 'Select * from #branchscan' uses a temp table. 
    I could see the work around saying use of table variable and global temp tables.  We are having around 100+ ssis packages which uses temp table for loading the data from a flat file and respective SP to process the data from the temp table.  above
    error is thrown during the pre-execute phase of the OLE db Destination, when trying to get the meta data of the table. 
    At this stage, it would be difficult for us to change the logic to global temp or TVP
    Thanks

  • MySQL temp tables or Calling Stored procedures in CS4

    I need to filter a result set by username before performing a LEFT JOIN and including OR IS NULL rows. The SQL works from from the mysqli client, by either creating a temp table using  "create temporary table temp_appts select * from..."  Or by creating a stored procedure which contains the same "create temp table" statement, then running my LEFT JOIN statement against the temp table.
    I have tried both in CS4, it accepts the code in "code view" without errors but the page in a browser loads as a blank or a 500 error in IE. In my experience, this is caused by exiting before reaching the html header.
    Is it possible to do either in CS4?  Below is the code I am using.
    $varU_temp_appts = "-1";
    if (isset(<?php $_SESSION['MM_Username'])){
    $varU_temp_appts =$_SESSION['MM_Username'];
    mysql_select_db($database_ess, $ess);
    $query_temp_appts = sprintf("CREATE TEMPORARY TABLE temp_appts SELECT * FROM appts WHERE username=%s", /GetSQLValueString($varU_temp_appts, "text"));
    $temp_appts = mysql_query($query_temp_appts, $ess) or die(mysql_error());
    $row_temp_appts = mysql_fetch_assoc($temp_appts);
    $totalRows_temp_appts = mysql_num_rows($temp_appts);
    mysql_select_db($database_ess, $ess);
    $query_todays_appts = "SELECT *  FROM appt_tm LEFT JOIN (temp_appts) ON appt_tm.appt_time=temp_appts.appt_hr WHERE(appt_date=CURDATE() OR appt_date IS NULL)";
    $todays_appts = mysql_query($query_todays_appts, $ess) or die(mysql_error());
    $row_todays_appts = mysql_fetch_assoc($todays_appts);
    $totalRows_todays_appts = mysql_num_rows($todays_appts);
    Any help is appreciated!

    chuck8 wrote:
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'appt_tm LEFT JOIN (temp_appts) ON appt_tm.appt_time=temp_appts.appt_hr where tem' at line 1
    I'm no expert on joins, but I know there were changes in MySQL 5.0.12 that resulted in queries that had previously worked failing. Go to http://dev.mysql.com/doc/refman/5.0/en/join.html, and scroll down to the section labelled Join Processing Changes in MySQL 5.0.12.

  • Temp tables in procedure

    Hi,
    I am trying to develop a procedure in which i have to create four tables to improve the performance of the procedure.
    is there any other way in which i can do this? i don't want to create four table objects. if i use global temporary table. then also it will create structure in DB. i tried with table of records method. that is getting too complicated since its a very big procedure.
    can anyone suggest me other ways of achieving this?

    user12288167 wrote:
    this procedure is called at the same time by 10 different interfaces. the procedure has 4 temp tables now, which are required to improve the performance. after all the processing is done it will insert the result into a final table. Temp tables are not required to improve performance. In fact, it slows things down and make performance worse.
    What db operation has the single largest performance impact? I/O.
    What does your so-called "+improvment+" do with temp tables? Generate more I/O for creating data in the temp tables and manipulate data in the temp tables.
    So, how can generating more I/O be a performance improvement??
    so we need separate tables for all these interfaces.i.e. 5*10=50 tables in all which is not acceptable by our project.
    or is there any way to implement wait in the procedure while it is being accessed somewhere else?You need to scrap that procedure entirely. It is pretty much junk and will perform like junk.
    There is very seldom a need for temp tables in Oracle. Very Important: The reasons for using temp tables in SQL-Server/Informix/etc DOES NOT exist in Oracle.
    In Oracle, readers of data NEVER blocks writers of data. And writers of data NEVER blocks readers of data. Oracle provides and guarantees read consistency. There is no need for temp tables to deal with the lack of data consistency or (unwarranted) read/write serialisation.
    Read up on Oracle read consistency - and use that, correctly. Without resorting to hacks like you had to do with temp tables in other (inferior) database products.

  • Crystal Reports Temp tables - Driving Me crazy

    Our ongoing saga with temp tables and crystal reports continues. I am ready to go crazy, so any help would be appreciated.
    Notes:
    I create the ##tempsmall table in query analyzer, so it is present when the code executes.
    When I use the sa/Corinne credentials, it works.
    When I use a non sa set of credentials, I get an error saying the temp table is not found.
    When I add the non sa user to the tempdb as a user, with DBO permissions, It works.
    Code is below
    Dim Report As New ReportDocument()
    Report.Load("C:\KI\Customers\Live Customers\Brookledge\ReportRD\CrystalReportsApplication1\Projects.rpt")
    Dim LogInfo As New TableLogOnInfo
    Dim Tbl As Table
    For Each Tbl In Report.Database.Tables
      LogInfo = Tbl.LogOnInfo
      LogInfo.ConnectionInfo.ServerName = "ocamb-vista"
      LogInfo.ConnectionInfo.DatabaseName = "mapps20"
      ' We need to figure out how to make this work with a non sa user?
      LogInfo.ConnectionInfo.UserID = "medequipuser"
      LogInfo.ConnectionInfo.Password = "mapps"
      'LogInfo.ConnectionInfo.UserID = "sa"
      'LogInfo.ConnectionInfo.Password = "corinne"
      Tbl.ApplyLogOnInfo(LogInfo)
    Next Tbl
    Report.Database.Tables.Item(0).Location = "tempdb.dbo.##tempsmall"
    Dim v As New Viewer
    v.CrystalReportViewer1.ReportSource = Report
    v.Show()

    Hi Scott,
    The problem is tempdb is only accessible by the Administrator account and they are typically not to be used by anyone other than the system. This is how SQL server works, any query being run will create a temp table for the DB server to use and pass that data to the calling query, once completed the tempdb is deleted.
    As you have seen, unless you set permissions each time for a specific user you don't have access to it. One option is to use real tables that you can populate and delete the rows of data each time. Not very efficient though.
    Crystal respects all DB permissions so it's not a CR issue.
    One possibility is in your front end you could use MS SQL Server API's, if there are any, or use a stored procedure to set permissions to the temp table before calling CR to set location. Sorry no samples to do this, its a DB server question.
    Another option is to write the data into a Data Set and then set the location to the DS for CR to use. If you have more than 5000 row though don't do this or your reports will have performance problems.
    CR does not have any API's that will allow you to access a table that it does not have permissions to get to. Basic DB security, you'll get the same log on error trying to connect ot any table that user doens't have access to.
    Thank you
    Don

  • Difference between tables statement and work area

    Hi
    i would like know the difference between these statement.
    tables: vttk.
    data :itab type standard table of vttk,
             wa_itab like line of vttk.
    what will happen with the table statement keyword ???
    whether any difference between the ouput created through tables and wa_itab statement???

    Hi
    HI,
    INTERNAL Table and it's background:
    ===================================
    Internal table acts as a container which is used to store the record sets. That is used to store the data fetched from the database table.
    So due to performance reason every time access to database would not be so good and decrease the performance. So you just select the data from the database and store it in the intermediate table. This table is called INTERNAL TABLE. So it's an replica of the database. The design foes like this,
    PRESENTATION SERVER <> APPLICATION SERVER <>
    DATABASE SERVER.
    So everytime gain accessing to database results in high resource usage and bad permformance.
    So always play around with internal tables. So obviously the whenever you access the data in the INTERNAL TABLE, the application server will be used.
    WORK AREA:
    ==========
    When ever you loop at the internal table, the current record should be stored in a temporary work place. That is called WORK AREA.
    LOOP AT ITAB INTO WORKAREA.
    ENDLOOP.
    ITAB :An internal table
    WORKAREA:An instance of internal table
    Go thru the link below
    Internal tables
    appending internal tables.
    <b>Reward if usefull</b>

  • Global Temp table with BLOB causing session crash

    Hi,
    i have a table as follows:
    create global temporary table spg_file_import (
    name varchar2 (128) constraint sfi_nam_ck not null,
    mime_type varchar2 (128),
    doc_size number,
    dad_charset varchar2 (128),
    last_updated date,
    content_type varchar2 (128),
    content long raw,
    blob_content blob
    on commit delete rows
    this is my 9ias 'document' table thats used to receive uploaded files which i modified to be global temporary.
    what i want to do is:
    a)upload a text file (xml)
    b) convert that file to clob
    c) store that file in new permanent table as clob
    d) commit (hence delete temp table rows as they are no longer necessary)
    to test it i have:
    CREATE OR REPLACE procedure daz_html
    as
    begin
    htp.p(' <FORM enctype="multipart/form-data" action="daz_fu" method="POST">');
    htp.p(' <p>');
    htp.p(' File to upload: <INPUT type="file" name="p_file_in"><br>');
    htp.p(' <p><INPUT type="submit">');
    htp.p(' </form>');
    htp.p('</body>');
    htp.p('</html>');
    end;
    CREATE OR REPLACE procedure daz_fu (
    p_file_in varchar2
    as
    -- BLOB Stream locator
    v_raw blob;
    v_clob clob;
    v_blob_length number;
    v_length number;
    v_buffer varchar2(32767);
    v_pos number := 1;
    begin
    -- Get xml document from transient 9iAs data store.
    select blob_content
    into v_raw
    from spg_file_import
    where name = p_file_in;
    -- create temp LOB
    dbms_lob.createtemporary(v_clob, false);
    -- get BLOB length
    v_blob_length := dbms_lob.getlength(v_raw);
    loop
    -- get length to read. this is set as a max length of 32767
    v_length := least((v_blob_length - (v_pos-1)),32767);
    -- assign BLOB to a varchar2 buffer in preparation to convert to CLOB
    v_buffer := utl_raw.cast_to_varchar2(dbms_lob.substr(v_raw, v_length, v_pos));
    -- now write out to the CLOB
    dbms_lob.writeappend(v_clob, v_length, v_buffer);
    -- increment our position.
    v_pos := v_pos + v_length;
    -- exit when we are done.
    exit when v_pos >= v_blob_length;
    end loop;
    commit;
    htp.p('commit done!');
    end;
    now if i upload a small text file (about 5kb) it works with no problem.
    however if I upload a large text file (say about 1Mb) it crashes oracle with:
    Fri, 26 Jul 2002 11:49:24 GMT
    ORA-03113: end-of-file on communication channel
    DAD name: spgd1
    PROCEDURE : daz_fu
    USER : spg
    URL : http://www.bracknell.bt.co.uk/pls/spgd1/daz_fu
    PARAMETERS :
    ============
    p_file_in:
    F22210/Document.txt
    this produces a large trc file.. the trace file indicates the crash occured on the commit; line
    Current RBA:[0x4eb0.117.10]
    *** 2002-07-26 12:35:11.857
    ksedmp: internal or fatal error
    ORA-00600: internal error code, arguments: [kcblibr_user_found], [4294967295], [2], [12583564], [65], [], [], []
    Current SQL statement for this session:
    declare
    rc__ number;
    begin
    owa.init_cgi_env(:n__,:nm__,:v__);
    htp.HTBUF_LEN := 255;
    null;
    daz_fu(p_ref_in=>:p_ref_in,p_type_in=>:p_type_in,p_file_in=>:p_file_in);
    if (wpg_docload.is_file_download) then
    rc__ := 1;
    wpg_docload.get_download_file(:doc_info);
    null;
    commit;
    else
    rc__ := 0; null;
    commit;
    owa.get_page(:data__,:ndata__);
    end if;
    :rc__ := rc__;
    end;
    ----- PL/SQL Call Stack -----
    object line object
    handle number name
    812b1998 42 procedure SPG.DAZ_FU
    819dff90 7 anonymous block
    ----- Call Stack Trace -----
    If i reaplce the temporary table with a non-temp table of the same structure i get no problems what-so-ever. Am I doing something that I shouldnt be with global temporary tables?
    Thanks.

    This is on Oracle 8.1.7.2

  • How to create the temp table in Sybase with values from Excel ?

    Dear Sir/Madam,
    I know this is not related with oracle DB, however i am in the need of help from you people who worked on Sybase. plz help me..
    I have the excel sheet which contains EmpId and EmpName values. I just wanted to read these two values one by one from an excel sheet and loaded them into one temp table in Sybase. is it possible thru sqlldr ?
    here is the sample code for your reference:
    begin tran
    create table tempdb..empIdName (emp_id int identity,emp_name varchar(50))
    go
    Awaiting for your valuable reply
    thanks
    pannar

    there is some hint provided by sybase user
    If it's Sybase IQ, you can export the excel file to a CSV file, then use a LOAD TABLE statement to get the data into your temporary table.
    For ASE, BCP would provide similar functionality.
    I am using ISQLW tool to work with sybase DB. what query to load the excel data to tem table in sybase. anyone who knows this? help me

Maybe you are looking for

  • ICloud Control Panel doesn't stay installed.

    I'm installing on a Win 8.1 64bit machine with Outlook 365 Home Premium.  The install seems to go well, but after I finish and the Control Panel closes, I have to reinstall it when I open it again.  Anyone have a suggestion?

  • My iPod Touch 2nd generation won't connect to the Internet

    After restoring my iPod Touch 2nd gen to factory settings because that's what iTunes advised me to do after doing the iTunes update a week ago, my iPod won't connect to the internet anymore. I was able to connect to our wifi but it won't go to any we

  • OIM 11g process implementation

    Hi All, We have a requirement where some roles(priviliges in the target app) are getting provisioned. Each role is considered as a separate resource instance and getting provisioned for users.And we have automated this process using schedulers where

  • SCCM Custom report

    Hi I have been asked to put together some custom reports out of SCCM 2012. Now I have looked through the reference for 2007 but there have been changes between the two products so now all the information is valid. I am hoping that someone has either

  • Largest hard drive in Ultra-10?

    I've got an Ultra 10 that I'd like to replace the hard drive in. Here are the specs on it: Motherboard: 375-0009 OBP: 3.31 CPU: 360 Mhz Memory: 512Mb OS: Solaris 9 with latest patch cluster as of September Right now It's got the 4.xx gig drive that c