Can't i use temp tables in regions?

Hi,
I'm trying to population 3 years fiscal year data in a single row, one for full time and other one for part time employees. So my output should look like this
Population Fy1_Tot Fy1% Fy2_Tot Fy1% Fy3_Tot Fy3%
FT 500 50.0 700 70.0 9000 90.0
PT 500 50.0 300 30.0 1000 10.0
Each fy1 data represents different month, based on the month I have to populate corresponding Fiscal year and I have take care this.
I could do this using TEMP table and works well in Toad but not in HTML DB? Can’t I use temp tables in regions?
Please see the query below
WITH TEMP AS(
SELECT INITCAP(FIELD_VALUE) as Population,
(CASE WHEN D_S_REP.SMC = :P14_MC_FY1 THEN TO_NUMBER(FYT3) END) as Total1,
(CASE WHEN D_S_REP.SMC = :P14_MC_FY1 THEN FYP3 END) as FY1P,
(CASE WHEN D_S_REP.SMC = :P14_MC_FY2 THEN TO_NUMBER(FYT2) END) as Total2,
(CASE WHEN D_S_REP.SMC = :P14_MC_FY2 THEN FYP2 END) as FY2P,
(CASE WHEN D_S_REP.SMC = :P14_MC_FY3 THEN TO_NUMBER(FYT1) END) as Total3,
(CASE WHEN D_S_REP.SMC = :P14_MC_FY3 THEN FYP1 END) as FY3P
FROM D_S_REP
WHERE FIELD_NAME='POPULATION'
AND RS_YR LIKE '%'||TRIM(:P14_S_YR) || '%'
AND D_S_REP.SMC IN (TRIM(:P14_MC_FY1),TRIM(:P14_MC_FY2),TRIM(:P14_MC_FY3))
AND WP_NAME = TRIM(:P14_WP_NAME)
AND RDL_NAME LIKE '%'||TRIM(:P14_EMPLOYEES)||'%'
GROUP BY FIELD_VALUE,D_S_REP.SMC, FYT3,FYP3,FYT2,FYP2,
FYT1,FYP1)
SELECT Population, SUM(Total1), SUM(FY1P), SUM(Total2), SUM(FY2P),SUM(Total3), SUM(FY3P) FROM TEMP
GROUP BY Population
Any thoughts!!
Thanks
CK

Actually the same query works well, in HTML DB too. it was my fault i placed the query in a wrong region so i was getting error..
Thanks

Similar Messages

  • DESKI Report using Temp tables in MS- SQL server 2005

    Hi,
    I am trying to create a Free hand SQL DESKI report using temp tables in MS SQL Server-2005, I am using ODBC connection.
    When I run the report, I am getting the error
    u201CConnection or SQL sentence error (DA0005) No column or data to fetchu201D
    Ex:
    Select *
    into #t1
    from region
    select * from #t1
    drop table #t1
    Please help.
    Regards,
    Pratik

    Pratik, the SQL does not seem right. BTW you can only retreive data via Deski Free hand SQL. Also try to use OLE DB connection.

  • Stored Procedure uses Temp Tables

    C#, asp.net app.
    I have a stored procudure that outputs data to temp tables. The data in these tables is only there for the life of that connection. The stored procedure does NOT return data.
    Options I see so far:
    1) If I open a connection and execute the stored procudure, how can I get crystal to use the SAME connection object?
    2) Can I get crystal to call the stored procedure for me first (but remember, it doesn't use the sp as the actual data source). Would I still be able to supply parameters to the SP?
    3) I guess I could do everything myself, even load all the data out of the temp tables into local datasets. And then supply the datasets to the tables. I tried this and I called SetDataSource on all my tables but then it looks like it still tried to go to the server again as I got a login screen.

    Hello Happy,
    No, Crystal does not have any access to those temp tables. They are locked by the owner who made the call and we have no API available in .NET that you can ride on to get access. Unless you can figure out a way at runtime to give full permission to the temp table then CR can use it. You just need to set the datasource to the temp table name at runtime. You will need to create the table so a report can be designed off it first but once done as long as the structure doesn't change the report will continue to work.
    Other options are as you have tried using data sets. Another option is to export that data into a database so CR has access to it rather than using temp tables. Once the report is done you can use MS API's to delete all rows of data.
    Thank you
    Don

  • Using Temp Tables

    I'm creating a temp table inside my program. Is there any way to force the database to keep the temp table's contents in memory, rather than flsuhing it to temp disk?

    This is nothing to do with temporary tables.
    The simplest way is to use UNION operator. This will provide you with the unique combination of rows from the two selects:
    select * from test_gtt
    union
    select '01-07-11 00:00:00',     'level1a',     'level2a', daycount      from gtt_daycount_test
    /It's not necessarily the most efficient way of doing things but then, if you're using temporary tables performance probably your num ber one concern.
    Cheers, APC

  • How to use temp table/variable

    Hello,
    It's SQL 2008 R2. I need to bring data from Oracle using .Net Providers/ODBC Data Provider to MS SQL table converting Oracle UTC dates to PST.  The source connection type cannot be changed as it's given. For the Destination I'm using the OLE DB.
    As the truncate all and load could take time I'm trying to use a temp table or a variable to use it further with t-sql merge or not exists to bring/add the only new records to the destination table.
    I'm trying different scenarios that is all failed.
    Scenario A:
    1. In DTF after OLE DB Source I'm using the Derived Colum to convert dates. It's working well.
    2. Then use Recordset Destination with an object variable User::obj_TableACD. It's also working well.
    3. Then I created a string variable with a simple query that I could modify later "select * from " + (DT_WSTR,10)@[User::obj_TableACD] trying to get data from the recordset object variable but it's not working.
    Scenario B:
    1. Created a store procedure to create a temp table.
    2. Created a string variable to execute SP str_CreateTempTable: "EXEC dbo.TempTable". It's working well with the SQL Task with SQLSourceType as Variable.
    3. Then how to populate the temp table from the Oracle source to bring data into the Destination?
    I could spend another few days to figure it out. So, please help me on it if there is a way to solve it.
    Thanks

    Thank you so much, Nitesh. Now, I got the understanding of temp tables in SSIS. However, in my case to implement t-sql merge or not exists to bring the new records only I'd need to load at least a one table into a temp table anyway. So, why not to use a
    destination table instead. I also noticed a one remark from the article you suggested that the expert who wrote the article had never actual used the temp tables in SSIS.
    So, I decided to go with truncate, drop keys, derive columns, load, and create keys again in the destination table.
    Thank you again, I'll reserve the knowledge I got for the temp SSIS tables for some other cases.

  • How can I list used database/table size resp user space ? Compression after

    How can I list used + maximum tablespace/database/table size of an Oracle database ?
    How can I list the space used currently by a user resp. his tables+indizes ?
    By the way: If I delete a user or table from an Oracle database installation: are then only the entires deleted
    or is the space released as well ?
    In otherwords: After I deleted a user resp. table is it recommended to do something like a "compress" similarly to Outlook
    or other eMail clients to shrink really the occupied space on hard disc ?

    I hope this helps you
    select df.tablespace_name "Tablespace",
    totalusedspace "Used MB",
    (df.totalspace - tu.totalusedspace) "Free MB",
    df.totalspace "Total MB",
    round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace))
    "Pct. Free"
    from
    (select tablespace_name,
    round(sum(bytes) / 1048576) TotalSpace
    from dba_data_files
    group by tablespace_name) df,
    (select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_name
    from dba_segments
    group by tablespace_name) tu
    where df.tablespace_name = tu.tablespace_name;

  • How we can update cube using Change Tables as Source

    I have created a cube using source tables. I have also created change table (feature of 9i) based on source table. which store new changes to souce table. I want to load cube using one mapping from source table or change table based on the validity of the change table.
    Is that possible to do this? have anybody implemented change table to incremental load of cube?
    Sanjiv Tyagi

    Hi Sanjiv,
    I can think of 2 ways of doing this:
    one is using a single mapping with a pre mapping process to determine whether the change table is valid. If yes the pre mapping process creates a view (that is also referenced in the mapping itself) on top of the change table (select * from change_table), if this is not valid then the view will be on the source table (select * from source). After this pre map process the mapping runs on which ever view exists and loads the data.
    the second way is using process flow and 2 mappings. In PF you have a PL/SQL call that verifies which data to use. If the change table is correct, that will give success and uses the mapping on the change table. If the return is Error then you use the mapping on the source table.
    I have not implemented these solutions, however I think these are 2 ways of getting it to behave like you would want to...
    Hope this gives you some ideas,
    Jean-Pierre

  • Can firefox be used for table

    i just bought a table can i put firefox on it i love used it
    duplicate of [/questions/1022323]

    Firefox will not run on Microsoft Windows RT. If you are running Windows on an Intel or AMD CPU then you can get Firefox from https://www.mozilla.org/firefox/all/

  • Stored procedure call returns null result set when using temp table in sp!

    Here's a really odd problem...
    SQL Server stored procedure called sp_Test takes 1 input INT. Here is the code I call it with
    cStmt = connection.prepareCall("{call sp_Test(?)}");
    cStmt.setInt(1, 44);
    cStmt.execute();
    rs = cStmt.getResultSet();When the body of the stored proc is
    CREATE PROCEDURE sp_Test(@i_NodeID INT)
    AS
    BEGIN
      SELECT node_id FROM tbl_NavTree
    END
    GOthe query works and I get all node_id back in rs
    BUT when the body of the stored proc is
    CREATE PROCEDURE sp_Test(@i_NodeID INT)
    AS
    BEGIN
      CREATE TABLE #Descendants(
        descendant_id INT
      SELECT node_id FROM tbl_NavTree
      DROP TABLE #Descendants
    END
    GOThe rs comes back as NULL. Really really weird if you ask me. I also tried removing the DROP TABLE line just in case the SELECT had to be the last statement but still NULL.
    Final note is that BOTH the above stored proc bodies work when executed within SQL Server query analyser.
    Must be JDBC .. what can it be!??

    DROP TABLE #DescendantsMS SQL Server - right?
    Then don't drop the table.
    From the MS docs for "create table"
    Local temporary tables are visible only in the current session;
    A local temporary table created in a stored procedure is dropped automatically when the stored procedure completes. The table can be referenced by any nested stored procedures executed by the stored procedure that created the table. The table cannot be referenced by the process which called the stored procedure that created the table.

  • Please help - Can not use stored procedure with CTE and temp table in OLEDB source

    Hi,
       I am going to create a simple package. It has OLEDB source , a Derived transformation and a OLEDB Target database.
    Now, for the OLEDB Source, I have a stored procedure with CTE and there are many temp tables inside it. When I give like EXEC <Procedure name> then I am getting the error like ''The metadata  could not be determined because statement with CTE.......uses
    temp table. 
    Please help me how to resolve this ?

    you write to the temp tables that get created at the time the procedure runs I guess
    Instead do it a staged approach, run Execute SQL to populate them, then pull the data using the source.
    You must set retainsameconnection to TRUE to be able to use the temp tables
    Arthur My Blog

  • 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

  • How to read the data file and write into the same file without a temp table

    Hi,
    I have a requirement as below:
    We are running lockbox process for several business, but for a few businesses we have requirement where in we receive a flat file in different format other than how the transmission format is defined.
    This is a 10.7 to 11.10 migration. In 10.7 the users are using a custom table into which they are first loading the raw data and writing a pl/sql validation on that and loading it into a new flat file and then running the lockbox process.
    But in 11.10 we want to restrict using temp table how can we achieve this.
    Can we read the file first and then do validations accordingly and then write to the same file and process the lockbox.
    Any inputs are highly appreciated.
    Thanks & Regards,
    Lakshmi Kalyan Vara Prasad.

    Hello Gurus,
    Let me tell you about my requirement clearly with an example.
    Problem:
    i am receiving a dat file from bank in below format
    105A371273020563007 07030415509174REF3178503 001367423860020015E129045
    in this detail 1 record starting from 38th character to next 15 characters is merchant reference number
    REF3178503 --- REF denotes it as Sales Order
    ACC denotes it as Customer No
    INV denotes it as Transaction Number
    based on this 15 characters......my validation comes.
    If i see REF i need to pick that complete record and then fill that record with the SO details as per my system and then submit the file for lockbox processing.
    In 10.7 they created a temporary table into which they are loading the data using a control file....once the data is loaded into the temporary table then they are doing a validation and updating the record exactly as required and then creating one another file and then submitting the file for lockbox processing.
    Where as in 11.10 they want to bypass these temporary tables and writing it into a different file.
    Can this be handled by writing a pl/sql procedure ??
    My findings:
    May be i am wrong.......but i think .......if we first get the data into ar_payments_interface_all table and then do the validations and then complete the lockbox process may help.
    Any suggestions from Oracle GURUS is highly appreciated.
    Thanks & Regards,
    Lakshmi Kalyan Vara Prasad.

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

  • How to work on temp table in oracle 10g

    Hi Guys,
    I have one simple procedure and it is returning some records through dbms_output.put_line.
    cursor c1 is select object_name from t_Turbo;
    type c1_type is table of c1%rowtype;
    rec1 c1_type;
    begin
    open c1;
    loop
    fetch c1 bulk collect into rec1 limit 200;
    for i in 1..rec1.count loop
    dbms_output.put_line(rec1.i);
    end loop;
    exit when c1%notfound;
    end loop;
    end;
    Now i am plaing to use temp table at dmbs_output.put_line in place and from there I want to select the records.
    Can any one help me on this.
    Thanks in advance!
    Regards,
    KLR

    This is what you need.
    create or replace procedure test ( pRet out sys_refcursor )
    as
    begin
      open pRet for select object_name from t_Turbo;
    end;SYS_REFCURSOR is a cursor type defined by oracle. You can define your owner.

  • Global temp tables in procedures

    Hi,
    Can we use two global temporary tables in a procedure.
    also is there a restriction that we can not call global temp tables more then once.
    and what are the other restriction with global temporary tables
    regards
    Amit

    Hi,
    Can we use two global temporary tables in a
    procedure.Yes
    >
    also is there a restriction that we can not call
    global temp tables more then once.How do you call a table?
    >
    and what are the other restriction with global
    temporary tablesNo restriction, but be careful on how the GTT is defined - on commit preserve rows or on commit delete rows.
    >
    regards
    Amit

Maybe you are looking for

  • Every so often my iMac acts like I have two screens

    Especally with email, I find one email is on the screen but I then need to select mail in the dock to get to "the other screen." How to stop this?

  • Block on PL/SQL Table of Record

    Hi, I am using Developer 6 with Oracle 8i, I based my block on PL/SQL procedure returning table of record, the form is running fine, but when ever I try to get data set, more then 200 rows, first it gows for query, working for a moment and then close

  • How to control the data rate of a digital write to a port on a PCI-6509

    I am using a PCI-6509 to write digital words to a custom digital board. I can generate the proper patterns with the 6509 but the resulting pulse rates are very high (150+ khz) which is very noisy. I know the board cannot have its clock controlled. Is

  • Sequence audio format stuck on 32-bit Floating Point

    Hi, The audio format for all my sequences is set to 32-bit Floating Point when I check them in the browser's Aud Format field. When I manually change the format in the sequence settings nothing changes in the browser and choosing a new sequence set u

  • Green/Red Line Appears on .mov when exporting

    Hi, There's a green/red line that appears on the RIGHT SIDE when I export my presentation to QT. I'm using H.264 @ 24fps with Multipass encoding at best quality. I'm not including audio or transparency. The slide size is 355x200. The contents are vec