How to create temporary tables in stored procedures.

Hello

I am new to oracle, I have a requirement where I need to run a query in a loop for different values of where condition. Here, I need to record the results of the query on each iteration. After the end of the loop, I need to send the results to the front end. I did a lot of research for the concept of the temporary table in oracle, but I found myself unresolved except headaches. Everyone is showing how to create temporary tables in general but not in stored procedure.

Bad, I need the concept of temporary tables, or is there an alternative way to store temporary results. My procedure looks like this.

create or replace
procedure uspMatchCode (parWord varchar2, p_recorderSet to types.cursor_type)
as
smallint parCnt;
Start
parcnt: = 0;
Select count (1) in parCnt of...;
If parcnt > 0 then
Open for P_recorderSet
Select field1, field2, field3,... of table1, table2, table2 where < < condition > >
on the other
-Here, I want to create a temporary table and store the result for the loop shape into the temporary table.
CREATE TEMPORARY TABLE global my_temp_table (NUMBER of Column1, Column2) ON COMMIT DELETE ROWS.
FOR parCnt in 0.3
loop
INSERT into my_temp_table select Field1, Field2, field3,... from table1, table2, table2 where < < condition > >
end loop;
Open for P_recorderSet
Select * from < < temporary table > >
end if;
end;

Any help would be great to check me on the problem.

Thank you
Kiran.

This is a change to the query Kiss has posted:

with data_text like)
Select regexp_substr (' sales financing marketing ',' [^] +', 1, level ") val
of tconnect by level<= length('sales="" finance="" marketing')-="" length(replace('sales="" finance="" marketing','="">
)
Select * from t, data_text, where t.colname like '% "| data_text. Val |' %'

This will help you. Please change the column names and the name of the table as a result

Tags: Database

Similar Questions

  • Dynamic temporary Table in stored procedure

    Dear expert,

    I'm trying to convert a database from MSSQL to Oracle 11 g. But I'm a little stuck on dynamic temporary tables in stored procedures.

    MS is normalize the data out dynamic SQL statements. In TSQL so I've created a Temp table with the number of columns that the SQL statement has, that I executed the SQL statement in the temporary table and then I was going to all the columns with the prompting separate command standard. Finally, I wrote the key table.

    If I want to do this process with only on SP, dynamic, rather than to define for each normalization process its own SP, so this possiple in Oracle?

    For example. "INSERT INTO Temp (PartNo, Descr, Type, price) SELECT PartNo, Descr, price from parts.

    PartNo. Descr | Type | Price
    AB00 | AKER GD245 | Monitor | 200.00
    AB01 | Samir QQ22 | Monitor | 120.00
    AQ05 | HB 5500DN | Printer | 550.00

    SELECT @R = Max (PartKey) of N_Parts
    INSERT INTO N_Parts (PartKey, PartNo) SELECT RowNum + @R, PartNo FROM (SELECT DISTINCT PartNo FROM Temp INCLUDING PartNo NOT IN (SELECT PartNo of N_Parts));
    SELECT @R = Max (PartDKey) of N_PartsDescr
    INSERT INTO N_PartsDescr (PartDKey, Descr) SELECT RowNum + @R, Descr FROM (SELECT DISTINCT Descr FROM Temp WHICH Desrc NOT IN (SELECT Desrc from N_Parts));
    ...

    Insert into Part_Data (PartKey, PartDKey, PartTKey, PartPKey)
    SELECT T0. PartKey, T1. PartDKey, T2. PartTKey, T3. Temp PartPKey T
    INNER JOIN N_Parts T0 to T0. PartNo = T.PartNo
    JOIN IN-HOUSE...

    So what is the best way, do not generate this dynamic Table Temp?

    Published by: 926165 on 08.04.2012 08:26

    926165 wrote:
    I'm trying to convert a database from MSSQL to Oracle 11 g. But I'm a little stuck on dynamic temporary tables in stored procedures.

    Just my 2 cents here.

    Conversion of database provider A to B of database provider is never really a great idea. The products are fundamentally different in many ways. Analysis of demand that needs to be ported from database at database B and then its implementation in a specific way to take advantage of the features of your new environment, accounting for all the differences between the implementations of provider will be your best bet.

    I say this because, for me at least, a conversion means that you take what you have and it in slam in what you need. The better approach is to analyse, design (to explain the differences in behavior between vendor implementations, such as mechanisms for read consistency) and proceed from there. This way, you have a solid base on which to start, instead of a skyscraper built out of toothpicks.

    See you soon,.

  • Create temporary table in the procedure

    I have a procedure which can be called at any time by multiple users. So I cann't use table in there, because on each call, the table is truncated and inserted. How can I create a temporary table in the procedure?

    Temporary tables in Oracle are different from other RDBMS like SQL Server.

    In Oracle, you create a global temporary table ONCE as part of the design of your database.

    create a global temporary table MyTableName (... columns...) on commit preserve rows;

    You can then use this table in your code as you would any other table.

    The difference is that any data that you insert in this table are only available/visible so that the code runs in the session, and if delete you / truncate the table it only removes the data for this session.  In this way, several sessions we can table without interfering with each other.

    (Note: instead of "preserve" you can change this to "delete" If you want that deleted data automatically when a commit is issued in your session, otherwise the data will be automatically deleted at the end of the session)

  • Temporary tables in stored procedure

    Hello

    I write a stored procedure that will get data from different sources and generates a spreadsheet finally. Initial selection gets the basic data and chooses then merges the data.

    To do this, I created a table in the database, I'm filling in data in this table by using the same procedure and finally selection of data in this table to generate the worksheet.

    Now, I plan to use the TEMPORARY table instead of create database table. Can someone tell me where I can watch examples for temporary tables?

    What is the best option in performance wise?

    or

    I can handle the whole scenario with slider? examples?

    Hello

    Why you cannot use an ordinary table?

    Search for [Global Temporary | http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_7002.htm#sthref7247] in the diocumentation, including SQL * manual language, an alternative.

    'Temporary' applies only to the data. A global temporary Table is created once and remains until you DROP, the same as any other table.
    The data in the table are temporary. If you create the table by saying "ON COMMIT PRESERVE ROWS" (which seems appropriate, according to your description) the data will be automatically deleted when you end the session database.

    All global data in temporary Tables are specific to the session. If two (or more) people use the same table at the same time, each one will see data that they inserted themselves; they'll never see rows inserted by the other session.

    Almost everything you can do with an ordinary table, you can do with a global temporary Table. In particular, DML (such as FUSION) and cursors work exactly as they do on other tables.

  • How to create a temporary table in a procedure.

    How to create a temporary table in a procedure.

    Hello

    user9093700 wrote:
    How to create a temporary table in a procedure.

    Why create a temporary table in a procedure?

    Oracle has soemthing called a global temporary Table , where the table is in fact permanent, but data is automatically deleted at the end of the session (or the transaction, depending on how the table was created). What did you talk about? Why do you want to create one in a procedure?

    Temporary tables, in the sense of the tables that are created on the fly and fell just as they are used, are almost never a good way to do anything in Oracle. Explain what you want to do, and someone will help you find a good way to do it.

    If you need really to create a table (or any other kind of DDL) in a procedure, use EXECUTE IMMEDIATE.

  • How to create a table in a stored procedure

    Please help me to answer the following question...

    How to create a table inside the stored procedure... I want a detailed explanation... Please help me

    Please see this link:
    http://tinyurl.com/cmq5vo

  • Create a journal of stored procedure when it is run through dbms_jobs...

    Hello everyone,

    I have a stored procedure that we run it through dbms_jobs...

    I wanted to print the dbms_output of my stored procedure in a log file or in short I just wanted to create logs for this stored procedure...

    I know that if I run this procedure using cron, I'll be able to create a log file...

    But how can I do this using dbms_jobs

    Database version: 10.2.0.1

    Any help would be great...

    Thank you

    If the answer has helped you please mark it as Correct or relatively useful so another can benefit.

    With greetings
    Krystian Zieja
    [Project Envision | http://www.projectenvision.com]

  • 5.6.1 pages: How to create a table with more than 999 lines?

    5.6.1 pages: How to create a table with more than 999 lines?

    The table on Pages v5.6.1 line selector is limited 3-digit, as it is in Pages ' 09 v4.3. Either use LibreOffice Writer, who does not have any constraint line on processing tables 3-digit, or any application spreadsheet for top 3-digit row needs.

  • How to create a table in if/else or structure without 0-case?

    Hello

    I tried to do for a while now.

    I only managed to think about this in three ways:

    1. (what I'm doing right now create the table through a loop for, fills the table in automatic indexing.) Filled it with many of if true and with a '0' if the value false. The idea was to remove the 0 later in the code. However, this seems very inefficient.

    2 make use of a registry change, which automatically adds the correct number of a table. The problem is that the table will keep growing and growing and at the very least would enormously slow down my program. At worst, it would break.

    So my question is: how to create a table that if a comparison is true, it puts the item in and if not, it does nothing?

    I have attached a PNG of my code snippet.

    Kind regards

    David.

    If you want to only affect exactly as much memory as you need for the table, you can count the number of true elements in the table of Boolean everything first and then assign one of exactly this size. In this way, you are more memory and time-efficient whether overuse (such as allocation of an array of I32 as big as the whole table boolean) or underallocating (from zero element and let it grow automatically whenever you add on).

    Count the true values, allocate an array only the great and then replace each value in this new table with indexes / "I ' value where the real exists." An excerpt from VI:

  • How to create a table?

    How to create a table in blackberry I'm usign blackberry jde class 4.7.which allows inorder to create a table with two columns and five rows.can someone give code example for this. I searched on google but I have not found a suitable.

    You can use GridFieldManager inorder to create lines and coloums... Here is a code example for dat:

    http://docs.BlackBerry.com/en/developers/deliverables/11958/Create_grid_layout_877557_11.jsp

  • How to create a table in a schema in the SOA database

    Hello

    can you please guide me how to create a table looks under custom schema available in the SOA database

    Thank you

    Valsaint

    Hello

    1. use JDeveloper to connect to your schema custom: view > Database > Database Navigator > new connection

    2. set the mpdel of your table column names, types of data, constraints (primary key, not null, foreign key, etc..)

    3. use this simplified tutorial to create the table according to your model of table create statement - Oracle/PLSQL: CREATE TABLE statement

    4. execute the statement in the SQL of JDeveloper journal for the custom connection (point 1 above).

    Let me know if you need help!

    HTH,

    A.

  • How to create a Table of contents of a book as opposed to a single document?

    I'm working on a book with several chapters. Each chapter is a separate document joined as well as the rest of the book in InDesign. I have a table of contents in each document, and the hyperlink works very well when the document is exported to PDF. However, I was unable to create a single comprehensive contents table on the front of the book before Chapter 1. I tried everything I know how to create a table of contents for a single document, but that does not work for me with so many documents in the book. Is there something I missed? I'd appreciate any help in this regard.

    In the Options section of the Table of contents dialog box, there is a checkbox: Include book of Documents.

    What is checked, he must analyze each document in a book for styles to be used in the creation of the table of contents.

  • How to create the script to compile procedure files in oracle - urgent deadline...

    How to create the script to compile procedure files in oracle.    about to go live and have much .prc pkg in a directory usr/tmp/ar... Po... human resources etc. need to create a script to compile all the files in the folder, then do not open all necessary .prc suggestions on how to do it.   Thank you Tom.

    (1) an urgent need, ASAP,... are words that do not in a forum of volunteer. We are here to help if you need it now, for free, open a SR.

    (2) oracle procedures are not files.

    (3) I think you are trying to run operating system packages, no Oracle procedure. right?

  • How to create a table in muse

    Hello

    I'm new to muse

    you want to know how we can create a table in muse

    Hello

    Please visit the following link How to create a table with muse?

    Kind regards

    Aish

  • How to create a table of contents of several levels?

    How to create a table of contents of several levels, or at least a TOC of two levels, so that when you click on the sign '+' or something similar to the first level, the second level will increase?

    Select the item/s from the list Table of contents, and then use the arrows that will apear at the bottom of the skin Editor to move them to the right.  This will cause a new point TOC to appear as a cap for all items indented beneath it.

    Be aware that during the execution by clicking on this article of the topic does not operate the game to slide under him.  There is no that expand the group to show slides of the child. You will then need to click on the first slide of the child in the group to trigger playback.  Personally I don't like the way it works, but that's how it is.  Register a feature (like me) request if you want that it works differently in a future version of Captivate.

Maybe you are looking for

  • Can not start, help!

    Hello I use 16 G WiFi touchpad, I can not start my device, it's just to see the HP logo only, I think that my WebOS is dead, how can I get the OS and reinstall?

  • Can I create a Multiboot USB from OSX installation?

    I use a Mac Pro 2012 environment; run the Mavericks.  I want to create a Multiboot USB OS X installation disc using 1. Mavericks, 2. Yosemite, 3. El Capitan.  Is it possible to download copies separate installation 1. Mavericks, 2. Yosemite, 3. El Ca

  • using the .ini file created by EXE

    First of all I would like to say that I have a thorough knowledge of the .ini files and the need for them.  My question is related specifically to the .ini file that is created with the executable.  I searched the forum but have not found any instanc

  • HP pavilion dv7-6135dx

    Then out of no where, a few hours earlier, my laptop (HP Pavilion dv7-6135dx) started acting... First, it would show my wifi like "no internet, secure... In an attempt to "disconnect' to reconnect - I accidentally hit"turn off"- to which a person has

  • My PDFs cant open

    Hello everyone, my PDF files changed to Null... For example if the name of my file was e3 is now Null.e3 and adobe reader and Foxit Reader cannot open my files. ?