Working with temporary tables in PL/SQL processes

So I'm trying to write a PL/SQL process and I have some difficulty. Here's what I do:

-Create temporary tables
-Put the data in them
-Use the data in temporary tables to fill the main status table
-Remove temporary tables

I'm running into some problems when I try to create the tables. If I do as I would in SQL Server:

SELECT field1, Field2
IN TempTable1
Of


Then, I get an error saying that there is no such thing as TempTable1. If I say:

CREATE TABLE TempTable1 AS
SELECT field1, Field2
Of


Then I get "found CREATE, Expecting CASE or another statement." I know that to truncate or remove tables in a PL/SQL, I use EXECUTE IMMEDIATE. I do the same thing for the creation of a table? If this is the case, how can I use run immediately on a query with apostrophe inside multi-line?

Thank you!

Use of temporary tables in Oracle is different from MS Sql Server.
In Oracle, you create tables Temp the same way you would normally create a permanent table.
Search syntax "create a global temporary table.
Oracle global temporary tables are visible to all connections, but don't share all the data.
The data are visible only for connections that introduced the data and are removed on commit / rollback, or when the connection ends.
So Structure is permanent, data is temporary and exclusive to a single connection.

If your process should look like this:

Create global temporary tables - once - at the same time, you create all of the other tables in your system.

-Fill the temporary tables.
-use the data in temporary tables to fill the main report table
-remove the data from the temporary tables.

Information on the Temp in Oracle tables:
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14231/tables.htm#sthref2213

HTH
Thomas

Tags: Database

Similar Questions

  • Doesn't work with temporary tables

    I try to make 'between' select server-side:

    < cfquery name = "issueList" datasource = "HOTLINE" >
    CREATE TABLE ##tmpIssues (ROWNUM INT IDENTITY (1, 1) INT ISSUE_ID);
    INSERT INTO ##tmpIssues (ISSUE_ID)
    SELECT dbo. QUESTIONS. ISSUE_ID
    FROM dbo. QUESTIONS
    WHERE THE...
    SELECT...
    INNER JOIN ##tmpIssues AS TI on dbo. QUESTIONS. ISSUE_ID = TI. ISSUE_ID
    WHERE TI. ROWNUM BETWEEN #Evaluate (displayRows * (StartRowOptional - 1) + 1) # #Evaluate(displayRows * startRow) AND #;
    DROP TABLE ##tmpIssues;

    and receive:

    Execution of the SQL statement is not allowed.

    When I delete all of the code except for create temporary table - error remains. I can't believe that it is not possible to create a temporary table inside cfquery!

    That is what it is? How to handle this?

    Thanks for the reply.

    I replaced the temporary table with the table variable, and it works properly now. Yes, I feel that this temporary table could lead to disorders... If I used it in a stored procedure, called from this request - it would work okay maybe... But if I want to do is universal - I need to pass parameters to query inside? Hell...: \
    I know that table variables have their own drawbacks. But at least I can guarantee you that there is no conflict between users. I use about 50 records per page - I guess it's ok for var table.

    I wish I went back any recordset object and managed beaches via StartRowOptional & LignesMax... But the problem is that any recordset returns records too and I want limit on serverside also...

  • When users who are working with an Application based on SQL (accounting), application suddenly closes!

    When users working with an Application based on SQL (accounting), application closes without prompting.

    We have virtual server Hyper-v with SQL server 2008 sp1 - other departments report no problem just for accounting

    They can't really work...

    Thank you

    Hadad

    These MS Answers forums are intended for the home rather than the it professional user. I suggest therefore that repost you your question in the forums MS Technet here:

    http://social.technet.microsoft.com/Forums/en-us/categories/ .

    (I'm sorry, but I can't move this thread for you because the two forums are working on separate platforms)

  • Global temporary table in PL/SQL with XML

    Hello

    I have the impression that it is something strange or maybe I'm missing something basic.

    Step 1: Create a global Temp table that should not be specific transaction.

    create a global temporary table Temp01

    (

    NUMBER OF TICKET_ID

    , Varchar2 (10) of the REGION

    NUMBER OF THE YEAR

    , CO_ID VARCHAR2 (10)

    ) ON COMMIT DELETE ROWS.

    Step 2:

    My XML that goes as a parameter to a new function.

    < TICKET >

    < TICKET_ID > 38498051 < / TICKET_ID >

    the USA < REGION > < / REGION >

    < YEAR > 2014 < / YEAR >

    XYZ123 < CO_ID > < / CO_ID >

    < / TICKET >

    Step 3: Create a Stand Alone function:

    -drop function aagarwal.wr_creation;

    create or replace FUNCTION XML_FUNC

    (

    ret_msg out varchar2,.

    p_xmlval IN varchar2

    )

    RETURN varchar2

    is

    l_xmlval varchar2 (4000): = p_xmlval;

    V_CO_ID VARCHAR2 (10);

    V_CODE VARCHAR2 (10);

    BEGIN

    BEGIN

    INSERT INTO Temp01

    (

    TICKET_ID,

    REGION,

    BLEACHED,

    CO_ID

    )

    SELECT

    EXTRACTVALUE (XmlType (p_xmlval), "/ TICKET/TICKET_ID ') ID,.

    EXTRACTVALUE (XmlType (p_xmlval), "/ TICKET/REGION") REGION.

    EXTRACTVALUE (XmlType (p_xmlval), "/ TICKET per YEAR"),.

    EXTRACTVALUE (XmlType (p_xmlval), "/ TICKET/CO_ID ') CO_ID

    FROM DUAL;

    ret_msg: = 'SUCCESS';

    -SELECT CO_ID IN V_CO_ID of aagarwal. TEMP_STAGE_WR;

    -return ret_msg;

    EXCEPTION

    WHILE OTHERS THEN

    ret_msg: = sqlerrm;

    Return ret_msg;

    END;

    BEGIN

    SELECT CO_ID INTO V_CO_ID FROM Temp01;

    / * MERGE IN the site is

    With the HELP of aagarwal. TEMP01 T

    WE (T.co_id = se.code AND se.type_nm = ' TYPE' and se.src_nm = T.region)

    WHEN NOT MATCHED THEN

    INSERT (ID, SRCNM, CODE, TYPENM)

    VALUES (SHARED_SEQ. NEXTVAL, T.region, T.co_id, 'TYPE');

    -commit; */

    return ret_msg | "ACE" | v_co_id;

    END;

    END;

    /

    Fact - created function.

    NOTE: MERGE statement is blocked and if the function was created in sweetness.

    Step 4: Call the function

    declare

    l_out varchar2 (50);

    l_outr varchar2 (50);

    p_xml XMLTYPE.

    Start

    l_outr: = XML_FUNC (l_out, ' < TICKET >)

    < TICKET_ID > 38498051 < / TICKET_ID >

    the USA < REGION > < / REGION >

    < YEAR > 2014 < / YEAR >

    XYZ123 < CO_ID > < / CO_ID >

    (< / TICKET > ');

    dbms_output.put_line (l_outr);

    end;

    /


    Step 5: Check the value being inserted into the temporary Table:


    Select * from temp01;


    So far so good.

    THE PROBLEM:

    Now I want to tweek the XML_FUNC function above by uncommenting MERGE statement, which brings me to an error that is not differentiable:

    I.e. PL/SQL: ORA-00942: table or view does not exist in line on MERGE pointing to Temp01 statement.

    NOTE: I tested this Merge statement explicitly (as long as the execution of Stand Alone and also by calling via anonymous block PLSQL) and its absolutely perfect work. And SITE table exist.

    PS: I would be grateful, if there is a better way to write this code? I'm not a regular PLSQL developer and so badly can write the code of practice.

    Kind regards

    AAG.

    Using 11.2.0.3:

    Owner of all these three objects is DBA.

    Are you sure?

    After the release of:

    Select object_name, object_type

    of object

    where object_name in ('TEMP01', 'SITE', 'XML_FUNC');

    You must grant the explicit right to select on the table for the owner of the function if the owners are different.

    This works as expected for me (user DEV has all 3 items):

    Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0

    Logged in as dev

    SQL >

    SQL > create a global temporary table Temp01)

    NUMBER OF TICKET_ID 2

    3, Varchar2 (10) of the REGION

    4, NUMBER OF THE YEAR

    5, CO_ID VARCHAR2 (10)

    6)

    7. ON COMMIT DELETE ROWS.

    Table created

    SQL >

    SQL > create table site)

    Identification number 2

    3, srcnm varchar2 (10)

    4, code varchar2 (10)

    5, typenm varchar2 (10)

    6  );

    Table created

    SQL > create the sequence shared_seq;

    Order of creation

    SQL >

    SQL >

    SQL > create or replace FUNCTION XML_FUNC)

    2 p_xmlval IN varchar2

    3)

    4 RETURN varchar2

    5 is

    6 l_xmlval xmltype: = xmltype (p_xmlval);

    7. START

    8

    9 INSERT INTO Temp01

    (10)

    TICKET_ID 11,

    REGION 12,

    13 YEARS,

    CO_ID 14

    15)

    16. SELECT ID EXTRACTVALUE(l_xmlval, '/TICKET/TICKET_ID'),

    17 EXTRACTVALUE(l_xmlval, '/TICKET/REGION') REGION,

    18 EXTRACTVALUE (l_xmlval, ' / TICKET per YEAR ') YEAR.

    19 EXTRACTVALUE(l_xmlval, '/TICKET/CO_ID') CO_ID

    20 FROM DUAL;

    21

    22. MERGE IN site

    23. WITH THE HELP OF TEMP01 T

    (24)

    25 T.co_id = se.code

    26 AND se.typenm = 'TYPE '.

    27 and se.srcnm = T.region

    28)

    29 WHEN NOT MATCHED THEN

    30 INSERT (ID, SRCNM, CODE, TYPENM)

    31 VALUES (SHARED_SEQ. NEXTVAL, T.region, T.co_id, 'TYPE');

    32

    33 return "SUCCESS";

    34

    35 END;

    36.

    Feature created

    SQL >

    SQL >

    SQL > set serveroutput on

    SQL >

    SQL >

    SQL > declare

    2

    3 l_outr varchar2 (50);

    4

    5. start

    6

    7 l_outr: = XML_FUNC (')

    8 38498051

    9 USA

    10 2014

    11 XYZ123

    12    ');

    13

    14 dbms_output.put_line (l_outr);

    15

    16 end;

    17.

    SUCCESS

    PL/SQL procedure successfully completed

    SQL > select * from site;

    ID CODE TYPENM SRCNM

    ---------- ---------- ---------- ----------

    TYPE 1 USA XYZ123

  • Work with word tables in a game

    In my spelling game, I have pictures of words that is added to a text field, one at a time (in a loop). They are also divided into letters so that the player can click on a corresponding letter plate to copy the word. The current letter would be visible at 100% (alpha setting) and the other letters would be set at 80%.

    Divide each word works well you want just the word worldwide, divided into individual letters, BUT I want my game to be phonetic based - so sometimes the sound in a Word will have more than a letter for example for the word "elephant", the table would be: activeWord:Array = ['e', 'l', 'e', 'ph', 'one ', ' nt'] and there would be case tiles from letter with the ph - sound - and - nt - on click too.

    I guess that's where the work is done by arrays of arrays? I got 10 words per level and 30 levels. I will stop with each word in its sounds and to hardcode each word as I did above elephant.

    How to rewrite the loop below to place the 10 word in a level loop. After each level, I want a score to appear with the option to click Next for the next level.

    public var wordsL1:Array = ['elephant', 'a', 'of', 'off', 'walk', 'no', 'got', 'in', 'East', 'it'];

    private var tf:TextField;

    public var letterArray:LetterArray;

    public var tileTimer = new Timer (500,384);

    the constructor code

    public void WordArray(_tf:TextField)

    {

    TF = _tf;

    nextWordF();

    * Run letter tiles Start *.

    letterArray = new LetterArray();

    addChild (letterArray);

    tileTimer.addEventListener (TimerEvent.TIMER, gameLoop);

    tileTimer.start ();

    }

    public void gameLoop(timerEvent:TimerEvent):void

    {

    trace ("tile timer started");

    letterArray.gameLoop ();

    }

    * end *.

    function nextWordF (): void

    {

    if(wordsL1.Length>0)

    {

    activeWordF();

    populateMyWordBox();

    }

    on the other

    {

    Quiz is over

    }

    }

    private function activeWordF (): void

    {

    activeWordArray = wordsL1.shift ().split("");

    / / This table must be sent to the class that checks which letters are clicked (used in this class, if that's where the letters clicked are handled) so the letters clicked can be compared to the elements of activeWordArray.

    When clicked letters are completed for that Word, call nextWordF().

    }

    I'm not the most expensive of the documentation for neglecting issues of people who know their way around, but that will always go down to the reading of the selection index and what is around him. You already know that. You can split the circumstances of the special match in a table and match against them before providing a solution, but you already know that.

  • The Oracle 12 c memory option works with external tables?

    Hello

    Does anyone know if the external tables are also candidates for the benefit of the Oracle 12 c option in memory? I have read the documentation and white papers, and can't find any reference to external tables. If it is possible, we are very interested to know all about her, especially any limitation.

    Thank you.

    This is not the right forum for this question; This forum is for the memory of TimesTen database not Oracle database in memory option. These are completely different things.

    But it happens that I can tell you that no, external tables are not candidates for use with the In-Memory Option.

    Chris

  • .click on line works with php table - does not work with javascript array.

    Howdy,

    I met a very interesting problem today, and I hope that you will be able to help me.

    I have a page in which the upper part is php to read a table from the server and display the table, that the html page is under construction.

    Find data in a table, and each row is clickable, which click on move the user to another page, that is based on the selected line.

    Here are the relevant parts of the php code:

    -------------------------------------------------------------------------------------

    <? PHP

    echo "< id of the table = 'patienttable" cellpadding = 5px border = 0-size of police = 16px > ';

    echo "< tr > < th ="30"width >". "ID #". ". "" < /th > < th = "100" width >. "Family name". " "" < /th > < th = "100" width >. "" Name"". "< /th > < th ="100"width" > "."

    "Middle name". "" < /th > < th = "80" width >. "" DOB ". "" < /th > < th = '50' width >. """" Zip"." < /th > < th = '50' width >". "' Gender '. "" < /th > < th = "100" width >.

    'Phone '. "< /th > < /tr >";

    While ($row = mysqli_fetch_array ($result))

    {

    blah blah blah

    echo "< tr > < td = 'localid' id >". " $localid. "< table > < td >. $lastname. "< table > < td >. $firstname. "< table > < td >. $middlename. "< table > < td >". " $dob. "< table > < td >". " $physzip. "< table > < td >. $gender. "< table > < td >". " $phone1.       "< table > < /tr >";

    }

    echo "< / table >";

    ? >

    ------------------------------------------------------------------------------------------ ------------

    And here is the code to a click on a line:

    ------------------------------------------------------------------------------------

    $("#patienttable_tr").click (function () {}

    var passthis = $(this).find("#localid").html ();

    .post $("php/setsessionvariable.php",)

    {sessionval: passthis},.

    function {window.location.href = "root.php"}

    );

    });

    ------------------------------------------------------------------------------------------ -----------------

    EVERYTHING works fine - no problem - works now for about 2 months.

    Today, I started to build something similar, BUT! I can't read the data base at the top of the page, I have to do an ajax request, call the db and display the data in a table;

    This is annoying, fairly simple javascript code:

    ------------------------------------------------------------------------------------------ --------------

    $.ajax({)

    type: 'POST',

    URL: "findpatientbackend.php",

    data: {letterslastname: lastname},.

    data type: 'json ',.

    success: {function (result)}

    $("#div1").html("");

    If (result.length > = 1).

    {var output = "";}

    $("div1").html ("< id of the table =" findtable">" ");

    $(résultat, fonction (index, value) {} .each)

    output += '< tr > < td width = "100px" > < table > < id td 'localid' width = '100px' = > '.

    + value.localid + '< table > < td width = "100px" > ".

    + value.lastname + '< table > < td width = "100px" > ".

    + value.firstname + '< table > < td width = "100px" > ".

    + value.middlename + '< table > < td width = "100px" > ".

    + value.dob + '< table > < /tr > ";

    });

    $("#div1").html (output);

    $("div1").html ("< /table >");

    }

    },

    error: function() {alert ("error on the return") ;}}

    });

    ------------------------------------------------------------------------------------------ -----------

    And here's the code click on lines, almost IDENTICAL to the above:

    ------------------------------------------------------------------------------------------ -----------

    $("#findtable_tr").click (function () {}

    var passthis = $(this).find("#localid").html ();

    .post $("php/setsessionvariable.php",)

    {sessionval: passthis},.

    function {window.location.href = '... / root.php'}

    );

    });

    ------------------------------------------------------------------------------------------ -------------

    All of the "stuff" loading on the page very well, BUT it absolutely nothing happens when I click on a line.

    Playing around this afternoon, I did a "View Source" on the two pages and saw something VERY interesting;

    1. the table written in PHP is present, can be seen and thus is "clickable".click on jquery function.

    2 - the table is written in javascript is INVISIBLE! I do not see in the source view (but I can see it on the screen) and as a result .click function on he can't see either.

    Issues related to the:

    1. How can I make the table written in javascript 'clickable' - how can I do the 'visible javascript array '?

    2 would it be the use of '.html' show table to the div? Is there another way?

    And again, I thank you in advance for any help.

    Sounds like a question of 'timing', i.e. you bind the click event tothe elements that don't exist - they do not exist because the AJAX call is not yet complete.

    You can use jQuery . on() (previously . live()) method to bind events to the elements 'the future '.

    Another option is to bind the click after the AJAX event is done and the

    is drawn.

    I guess even one other option is to ask the JSON in PHP so that the

    is called before the page is delivered.

    Moreover, we see items created by JavaScript using 'View Source '. Use Firebug or Chrome/Safari "inspect element".

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.UK/

  • SQL procedure does not work with 'current cursor' Oracle 11 g

    Hi all
    I've written a procedure that should update all rows for a single column on a given table.
    Here is the code:

    CREATE OR REPLACE PROCEDURE "xxx". "" loop_update_autowert_x ".
    (
    number of startwert
    column_name VARCHAR2,
    table_name varchar2
    )
    AS

    stmt varchar2 (2000);
    stmt2 varchar2 (2000);
    number of zaehler;
    number of sum_gesamt;
    TYPE obj_ref_type IS REF CURSOR;
    obj_cur obj_ref_type;
    Start
    stmt2: = ' select rownum, rowid of | table_name | "for update";
    Obj_cur OPEN FOR stmt2;
    dbms_output. Enable (1000000);
    dbms_output.put_line (' ist Startwert: ' | startwert);
    dbms_output.put_line (' ist column name: ' | column_name);
    dbms_output.put_line (' ist Table name: ' | table_name);
    loop
    extract the obj_cur in zaehler, my_rowid;
    exit WHEN obj_cur % NOTFOUND;
    sum_gesamt: = zaehler + startwert;
    stmt: = "update". table_name | 'set ' | column_name | ' = ' || sum_gesamt | "WHERE the current of obj_cur";
    dbms_output.put_line (stmt);
    immediately execute stmt;
    end loop;
    close obj_cur;
    end;

    the error I get is:
    Anmeldung bei der data base Oracle Test2.
    ORA-03001: Funktion nicht solution
    ORA-06512: in "xxx.loop_update_autowert_x", line 29
    ORA-06512: In line 10
    Startwert ist: 5
    Column name ist: one
    Table Name is: T
    Update T set a = 6 WHERE the currents of obj_cur
    Process finished.
    Abmeldung von der data base Oracle Test2.

    have anyone an idea what is wrong or this construction with the clause "cursor open for the statement" is not possible with the current cursor location

    thx for help
    Best regards
    Hans-Peter

    When informed of the cursor works with static cursors and static sql only.

    ----------
    Sybrand Bakker
    Senior Oracle DBA

  • Get all the different values in a table - 'or array elements' does not work with I32

    Hello

    I just found out that "array elements or" does not work with a table 1 d of integer values. I didn't expect that.

    I did a semi quick forum search and did not find a pointer to an effective solution. Can someone give me a hint?

    Do not back my initial intention is to list all the values that appear in an array of integers.

    I thought that if I converted the figures for powers of 2 and or I had solved the problem at hand - only to discover that the elements of array does not.

    If someone could propose a different approach, I'd be happy too.

    I should mention that the execution time is a factor here - I need a fast code, but any suggestions are welcome because they could help me get started.

    Best regards Florian

    Hi Florian.

    try this:

    "Function, it seems, the table of GOLD ' is polymorphic (as written in the context-sensitive help), but does not support arrays of I32. At least the error message means just that...

  • Temporary tables in Oracle

    Hi all


    I develop a .net application with back-end in oracle 10g. I had previously worked with sql server 2005,2008 and I am new to oracle.

    I'm working on a query complex that requiries, the temporary table inside the procedure. In sql server easy to create and drop the temporary table inside the proc.

    Can I use a specific Transaction TWG to store and process temporary data inside my procedure? My web application must be linked to the database via a a username and a password. Since being a web background multi-user executes the procedure at the same time, registered under the same user name and password...

    I know it's a coomon question, but I need him...

    It is very complicated to use WITH SELCT or inline views etc...

    Thank you

    Kris.

    I know it's a coomon question, but I need him...

    If you know that this is a frequently asked question, then you must know the common answer. But we're going there repeat once more.

    In Oracle temporary tables are permanent objects. It was only the data in them that is temporary. So for your scenario, you should have the DBA create table once, like any other table.

    The thing with temporary tables is that each session sees its own data and nothing else. If your procedure can fill the table with data, treat it and send it back without a hitch.

    Since being a web background multi-user executes the procedure at the same time, registered under the same user name and password...

    Is not serious: the display of the data is controlled by session. If you do not have a problem providing the table is filled and the result set returned in a single call.

    It is very complicated to use WITH SELCT or inline views etc...

    Yes it's hard. Fortunately, CPUs get more powerful and continue to become cheaper, bandwidth so that our systems to continue to deal with the growing number of suck is code thrown at them. Is not Moore's law wonderful :)

    Cheers, APC

    blog: http://radiofreetooting.blogspot.com

  • Time dilation of a curve with interpolation table 1 d?

    Greetings,

    I'm trying to run a time dilation of a curve I used to work with the table 1 d of function interpolate VI. Basically, I have to perform the expansion on each segment, that is why each segment contains 100 points, where there are currently 60.

    I am currently working with two files (the two are broken) to compare because I'm not sure how to use the table 1 d interpolating VI, and what I have to enter for the fractional index. I know that the output of the table in the first for loop should go in the 1 d array interpolated somehow.

    I'm stuck!

    Thank you!

    TheLT

    I'm good I thought it

    Here's how to do it for later use.

    Code attached.

    TheLT

  • SELECT the data inserted into a global temporary Table in a stored proc

    A stored procedure is run from Oracle SQL Developer to insert data into a global temporary table. A SQL (in Oracle SQL Developer) worksheet is open to run a SELECT query to retrieve the data from the temporary table overall which was populated in the stored procedure. No row is returned. I guess it's because the stored procedure and the SELECT statement executed in different sessions.

    Is it possible to run the stored procedure in Oracle SQL Developer and then execute a select statement on the temporary table overall which was filled in the stored procedure by using the same connection so that the data can be extracted?

    I use version 1.5.1 build HAND-5440 of Oracle SQL Developer.

    In a worksheet, do something like

    Start
    insert_proc;
    end;

    Select * from my_temp_table;

    Place the cursor on each statement in turn and Press f9 (where it all began... the end is a single statement.

  • Table temporary global vs create and drop an ordinary table in pl/sql proc

    Hello!

    I currently have these statements in a pl/sql procedure:

    EXECUTE IMMEDIATE 'drop table tmp_deal;

    RUN IMMEDIATELY.
    create the table tmp_deal as
    Select deal_tracking_num, ins_num, tran_status
    ab_tran t, part p
    where 1 = 1
    AND t.internal = p.PARTY_ID
    AND p.sname in ("SXXX - YY", "ZZZNE - TT","FG - RT")
    and t.MAT_DATE > sysdate - 15 * 31
    AND t.status IN (1,3,4,11)';

    EXECUTE IMMEDIATE 'create index tmp_deal_idx1 on statistics calculation in line of tmp_deal (status, tracking_num);
    EXECUTE IMMEDIATE 'create index tmp_deal_idx2 on statistics calculation in line of tmp_deal (tracking_num, status);
    EXECUTE IMMEDIATE 'create index tmp_deal_idx3 on statistics calculation in line of tmp_deal (ins_num);


    As you can see I am falling and re-creating a table. The table is used as an intermediate storage for a larger SQL following further in my procedure (not shown in this post).

    My question is:
    Y at - it an advantage or a drawback in using global temporary tables (gtt) instead of the create and drop an ordinary table? The table contains about 7000 records and is not needed more once the procedure is complete. The procedure runs once per day, every day of the year

    We are running Oracle 9iR2.

    And finally, please do not look to find errors in SQL statements above. They are slightly darkened and still developing. The basic question is if TWG's benefit to the common way to do it.


    Thank you in advance for your help!

    user7066552, the use of temporary tables may be a necessity in SQL Server and mySQL, but with Oracle and its authors do not block readers reading model consistency using temporary tables as part of the treatment is generally unnecessary.

    A valid use for a table of work could be where you create an operating table that is used to generate reports that are run on demand and several different users need access to the same data. However, you create the work only one table and truncate it prior to restocking rather than drop and it dynamically create. When only the current process will use the data a TWG is the way to go if you must have a table that is "temporary".

    HTH - Mark D Powell.

  • execution of stored procedure in sql developer/sql more with a table setting?

    Hello

    I create a package with a procedure which has a cursor ref as output and a type as an input parameter.  Here is my definition of the package

    PACKAGE 
    -------
    CREATE OR REPLACE PACKAGE TEST
    As
      TYPE RefCursorType IS REF CURSOR;
      type intTableType is table of varchar2(50) index by binary_integer;
      
      PROCEDURE GETDATA (
              P_RECORDS OUT RefCursorType,           
               YEAR_LIST IN intTableType
      );  
    END;
    
    
    PACKAGE BODY
    -----------------------
    
    SET DEFINE OFF
    CREATE OR REPLACE PACKAGE BODY TEST
    AS 
    PROCEDURE GETDATA
    (
      P_RECORDS OUT RefCursorType,  
      YEAR_LIST IN intTableType  
    )
    AS 
    iYearList  IDTableType;
    BEGIN 
      --GET ARRAY COUNT
      IYEARLIST := IDTABLETYPE();
      IYEARLIST.EXTEND(YEAR_LIST.COUNT);
      
      --LOOP THROUGH LISTS AND POPULATE ARRAY
      FOR I IN YEAR_LIST.FIRST .. YEAR_LIST.LAST
      LOOP
      IYEARLIST(I) := IDTYPE(TO_CHAR(YEAR_LIST(I)));
      END LOOP;
      
       OPEN P_RECORDS FOR 
       SELECT CITHTML AS FORMATTED
        FROM dbTest.FORMATTED_HTML
      WHERE YEAR IN (SELECT * FROM TABLE(IYEARLIST))
      ;
      END GETDATA ;
    END TEST ;
    /
    
    

    I want to perform this procedure from the sql or sql developer more to see if it works properly.   The year field dbTest.FORMATTED_HTML is defined as varchar2 (20 bytes).  He has many years as well as text.

    I've used this in the past with simple stored procedures, but not those with a table setting

    var r refcursor;

    exec GETOLDDATA(:r,40);

    print r;

    How can I modify this to allow him to run my stored procedure?

    Thank you

    Just declare SQL, not type of PL/SQL:

    CREATE OR REPLACE

    TYPE Str50TblType

    AS THE TABLE OF THE VARCHAR2 (50)

    /

    CREATE OR REPLACE

    THE TEST PACKAGE

    IS

    GETDATA PROCEDURE)

    P_RECORDS ON SYS_REFCURSOR,

    YEAR_LIST IN Str50TblType

    );

    END;

    /

    CREATE OR REPLACE

    TEST OF PACKAGE BODY

    IS

    GETDATA PROCEDURE)

    P_RECORDS ON SYS_REFCURSOR,

    YEAR_LIST IN Str50TblType

    )

    IS

    BEGIN

    OPEN P_RECORDS

    FOR

    SELECT CITHTML AS FORMATTED

    OF dbTest.FORMATTED_HTML

    WHERE YEAR IN)

    SELECT *.

    TABLE (YEAR_LIST)

    );

    GETDATA END;

    END TEST;

    /

    SY.

  • Temporary table with dates

    I try to explain my problem:

    I have a query that lists sales grouped by day like this:

    SELECT S.DAY, SUM (S.AMOUNT)
    SALES S
    WHERE S.DAY BETWEEN SYSDATE-100 AND SYSDATE
    S.DAY GROUP

    I need the query also lists the days that were not given.
    I think the solution is to use a temporary table using subquery that has a list of values of days:

    SELECT D.DAY, SUM (S.AMOUNT)
    S (*) D, SALES
    WHERE S.DAY (+) = D.DAY
    GROUP OF D.DAY

    Anyone know how to create the subquery (*) with the list of all the days, from the range (for example, SYSDATE-100 to SYSDATE)?
    Thank you.

    Hello

    You'd have to utilze a little thing called a generator of line:

    SQL> select trunc(sysdate) -level your_date
      from dual connect by level < 10
    
    YOUR_DATE
    ---------
    16-FEB-11
    15-FEB-11
    14-FEB-11
    13-FEB-11
    12-FEB-11
    11-FEB-11
    10-FEB-11
    09-FEB-11
    08-FEB-11
    
    9 rows selected.
    

    Use it in your query in the form of conduct table and outer join to the table sales.

    Concerning
    Peter

Maybe you are looking for