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

Tags: Database

Similar Questions

  • 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

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

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

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

  • dbms_job. Submit insertion values in a table using stored procedure

    values are inserted into a table by using the stored procedure by using the sequence and creating a job to trigger after every 10 seconds...

    create table test (collar number);

    table created.

    create sequences seq_test
    start with 1
    Increment 1;

    order of creation.

    create or replace procedure sp_test is
    Start
    loop
    Insert into test values (seq_test.nextval);
    end loop;
    commit;
    end;

    created stored procedure

    Report the number of jobno;
    BEGIN
    DBMS_JOB. SUBMIT)
    jobs = >: jobno.
    This = > 'sp_test;',
    next_date = > TRUNC (SYSDATE + 1/1440).
    interval = > 'SYSDATE + 10/86400',.
    no_parse = > TRUE
    );
    COMMIT;
    END;

    stored procedure created successfully



    every thing is done, but why the feature is always wrong...
    Please help me

    Hello

    Lucien wrote:
    ...
    create or replace procedure sp_test is
    Start
    loop
    Insert into test values (seq_test.nextval);
    end loop;
    commit;
    end; ...

    Have you tested this procedure first? It has an infinite loop. If this is the case, it's inserting row after row in the table, but never to commit, because he never leaves the loop.

    It seems that what you posted is a much simplified version of what you really do. Simplify things for posting on this forum is a good idea, but this one is so simple that I don't see the point of it, so I can't offer a better way to do. Maybe you shouldn't have a loop in the process. Whatever you do, test it before you submit it as a job.

  • Insert table with stored procedure

    Hello

    is it possible to use bind insert table in odp.net that calls a stored procedure, or who loses the point of contact of the table?

    I need to do at once two insertions in a parent table and the child table (get the primary key generated by a sequence in the first table.). Don't know if this can be done without storing seq.next_val somehow?

    Edit: I will extend the question and ask if the table bind sql text can be a block anonymous plsql

    Edited by: KarlTrumstedt 16-jun-2010 02:49

    You can do both. You can table insert a stored procedure and an anonymous block.

    Here's how (these are based on the ArrayBind example provided with the installation of ODP.net/ODT.

    Installation program:

    create table zdept (deptno number, deptname varchar2(50), loc varchar2(50));
    
    CREATE OR REPLACE PROCEDURE ZZZ (p_deptno in number, p_deptname in varchar2, p_loc in varchar2) AS
    begin
        insert into zdept values(p_deptno , p_deptname || ' ' || p_deptname, p_loc );
    end zzz;
    
     /**
     drop table zdept ;
     drop procedure ZZZ ;
     **/
    

    table and link it to the stored procedure call:

       static void Main(string[] args)
        {
          // Connect
          string connectStr = "User Id=;Password=;Data Source=";
    
          // Setup the Tables for sample
          Setup(connectStr);
    
          // Initialize array of data
          int[]    myArrayDeptNo   = new int[3]{1, 2, 3};
          String[] myArrayDeptName = {"Dev", "QA", "Facility"};
          String[] myArrayDeptLoc  = {"New York", "Maryland", "Texas"};
    
          OracleConnection connection = new OracleConnection(connectStr);
          OracleCommand    command    = new OracleCommand (
            "zzz", connection);
          command.CommandType = CommandType.StoredProcedure;
    
          // Set the Array Size to 3. This applied to all the parameter in
          // associated with this command
          command.ArrayBindCount = 3;
          command.BindByName = true;
          // deptno parameter
          OracleParameter deptNoParam = new OracleParameter("p_deptno",OracleDbType.Int32);
          deptNoParam.Direction       = ParameterDirection.Input;
          deptNoParam.Value           = myArrayDeptNo;
          command.Parameters.Add(deptNoParam);
    
          // deptname parameter
          OracleParameter deptNameParam = new OracleParameter("p_deptname", OracleDbType.Varchar2);
          deptNameParam.Direction       = ParameterDirection.Input;
          deptNameParam.Value           = myArrayDeptName;
          command.Parameters.Add(deptNameParam);
    
          // loc parameter
          OracleParameter deptLocParam = new OracleParameter("p_loc", OracleDbType.Varchar2);
          deptLocParam.Direction       = ParameterDirection.Input;
          deptLocParam.Value           = myArrayDeptLoc;
          command.Parameters.Add(deptLocParam);
    
          try
          {
            connection.Open();
            command.ExecuteNonQuery ();
            Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
          }
          catch (Exception e)
          {
            Console.WriteLine("Execution Failed:" + e.Message);
          }
          finally
          {
            // connection, command used server side resource, dispose them
            // asap to conserve resource
            connection.Close();
            command.Dispose();
            connection.Dispose();
          }
        }
    

    "anonymous plsql block.
    Well Yes

        static void Main(string[] args)
        {
          // Connect
          string connectStr = "User Id=;Password=;Data Source=";
    
          // Setup the Tables for sample
          Setup(connectStr);
    
          // Initialize array of data
          int[]    myArrayDeptNo   = new int[3]{1, 2, 3};
          String[] myArrayDeptName = {"Dev", "QA", "Facility"};
          String[] myArrayDeptLoc  = {"New York", "Maryland", "Texas"};
    
          OracleConnection connection = new OracleConnection(connectStr);
          OracleCommand    command    = new OracleCommand (
            "declare dnumber number; dname varchar2(50) ; begin dnumber := :deptno;dname := :deptname;insert into zdept values (:deptno, :deptname, :loc); update zdept set deptname=dname || :loc where deptno = :deptno; end;", connection);
    
          // Set the Array Size to 3. This applied to all the parameter in
          // associated with this command
          command.ArrayBindCount = 3;
          command.BindByName = true;
          // deptno parameter
          OracleParameter deptNoParam = new OracleParameter("deptno",OracleDbType.Int32);
          deptNoParam.Direction       = ParameterDirection.Input;
          deptNoParam.Value           = myArrayDeptNo;
          command.Parameters.Add(deptNoParam);
    
          // deptname parameter
          OracleParameter deptNameParam = new OracleParameter("deptname", OracleDbType.Varchar2);
          deptNameParam.Direction       = ParameterDirection.Input;
          deptNameParam.Value           = myArrayDeptName;
          command.Parameters.Add(deptNameParam);
    
          // loc parameter
          OracleParameter deptLocParam = new OracleParameter("loc", OracleDbType.Varchar2);
          deptLocParam.Direction       = ParameterDirection.Input;
          deptLocParam.Value           = myArrayDeptLoc;
          command.Parameters.Add(deptLocParam);
    
          try
          {
            connection.Open();
            command.ExecuteNonQuery();
            Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
          }
          catch (Exception e)
          {
            Console.WriteLine("Execution Failed:" + e.Message);
          }
          finally
          {
            // connection, command used server side resource, dispose them
            // asap to conserve resource
            connection.Close();
            command.Dispose();
            connection.Dispose();
          }
        }
    
  • Tables created in a stored procedure cannot be used with dynamic SQL? The impact?

    There is a thread on the forum which explains how to create tables within a stored procedure (How to create a table in a stored procedure , however, it does create a table as such, but not how to use it (insert, select, update, etc.) the table in the stored procedure.) Looking around and in the light of the tests, it seems that you need to use dynamic SQL statements to execute ddl in a stored procedure in Oracle DB. In addition, it also seems that you cannot use dynamic SQL statements for reuse (insert, select, update, etc.) the table that was created in the stored procedure? Is this really the case?

    If this is the case, I am afraid that if tables cannot be 'created and used"in a stored procedure using the dynamic SQL, as is the case with most of the servers of DB dynamic SQL is not a part of the implementation plan and, therefore, is quite expensive (slow). This is the case with Oracle, and if yes what is the performance impact? (Apparently, with Informix, yield loss is about 3 - 4 times, MS SQL - 4 - 5 times and so on).

    In summary, tables created within a stored procedure cannot be 'used' with dynamic SQL, and if so, what is the impact of performance as such?

    Thank you and best regards,
    Amedeo.

    Published by: AGF on March 17, 2009 10:51

    AGF says:
    Hi, Frank.

    Thank you for your response. I understand that the dynamic SQL is required in this context.

    Unfortunately, I am yet to discover "that seeks to" using temporary tables inside stored procedures. I'm helping a migration from MySQL to Oracle DB, and this was one of the dilemmas encountered. I'll post what is the attempt, when more.

    In Oracle, we use [global temporary Tables | http://www.psoug.org/reference/OLD/gtt.html?PHPSESSID=67b3adaeaf970906c5e037b23ed380c2] aka TWG these tables need only be created once everything like a normal table, but they act differently when they are used. The data inserted in TWG will be visible at the session that inserted data, allowing you to use the table for their own temporary needs while not collide with them of all sessions. The data of the TWG will be automatically deleted (if not deleted programmatically) when a) a commit is issued or b) the session ends according to the parameter that is used during the creation of the TWG. There is no real need in Oracle to create tables dynamically in code.

    I noticed that many people say that the "Creation of the tables within a stored procedure" is not a good idea, but nobody seems necessarily explain why? Think you could elaborate a little bit? Would be appreciated.

    The main reason is that when you come to compile PL/SQL code on the database, all explicit references to tables in the code must correspond to an existing table, otherwise a djab error will occur. This is necessary so that Oracle can validate the columns that are referenced, the data types of those columns etc.. These compilation controls are an important element to ensure that the compiled code is as error free as possible (there is no accounting for the logic of programmers though ;)).

    If you start to create tables dynamically in your PL/SQL code, so any time you want to reference this table you must ensure that you write your SQL queries dynamically too. Once you start doing this, then Oracle will not be able to validate your SQL syntax, check the types of data or SQL logic. This makes your code more difficult to write and harder to debug, because inevitably it contains errors. It also means that for example if you want to write a simple query to get that one out in a variable value (which would take a single line of SQL with static tables), you end up writing a dynamic slider all for her. Very heavy and very messy. You also get the situation in which, if you create tables dynamically in the code, you are also likely to drop tables dynamically in code. If it is a fixed table name, then in an environment multi-user, you get in a mess well when different user sessions are trying to determine if the table exists already or is the last one to use so they can drop etc. What headache! If you create tables with table names, then variable Dynamics not only make you a lot end up creating (and falling) of objects on the database, which can cause an overload on the update of the data dictionary, but how can ensure you that you clean the tables, if your code has an exception any. Indeed, you'll find yourself with redundant tables lying around on your database, may contain sensitive data that should be removed.

    With the TWG, you have none of these issues.

    Also, what is the impact on the performance of the dynamic SQL statements in Oracle? I read some contrasting opinions, some indicating that it is not a lot of difference between static SQL and SQL dynamic in more recent versions of Oracle DB (Re: why dynamic sql is slower than static sql is this true?)

    When the query runs on the database, there will be no difference in performance because it is just a request for enforcement in the SQL engine. Performance problems may occur if your dynamic query is not binding variable in the query correctly (because this would cause difficult analysis of the query rather than sweet), and also the extra time, to dynamically write the query running.

    Another risk of dynamic query is SQL injection which may result in a security risk on the database.

    Good programming will have little need for the tables of dynamically created dynamically or SQL.

  • SQL dynamic stored procedure call

    I want to run the following command (which I build dynamically) to pl/sql, stored procedure, but I get the error message
    How can I run this command from pl/sql after I built it dynamically?


    exec RESEND_MISSING_UFMS (June 5, 13 04.00.00.000000000 AM ', June 6, 13 04.00.00.000000000 AM', 'VPS'); < < works very well on the sql prompt.


    create or replace procedure tranhost.ufm_resubmit
    AS
    v_time1 varchar2 (50);
    v_time2 varchar2 (50);
    cmd_str1 varchar2 (100);
    cmd_str2 varchar2 (100);

    BEGIN
    Select to_char (sysdate-1,' MON-JJ-AA "") in the double v_time1;
    Select to_char(sysdate,'DD-MON-YY') in the double v_time2;

    -next fails with ORA-00900: invalid sql statement.

    immediately run "exec RESEND_MISSING_UFMS('''||) v_time1 | "04.00.00.000000000 AM","' | v_time2 | ("04.00.00.000000000 AM VPS",""); " ;

    END;
    /
    CREATE OR REPLACE PROCEDURE tranhost.ufm_resubmit
    AS
       v_time1    VARCHAR2 (50);
       v_time2    VARCHAR2 (50);
       cmd_str1   VARCHAR2 (100);
       cmd_str2   VARCHAR2 (100);
       var_sql    VARCHAR2 (300);
    BEGIN
       SELECT TO_CHAR (SYSDATE - 1, 'DD-MON-YY')
         INTO v_time1
         FROM DUAL;
    
       SELECT TO_CHAR (SYSDATE, 'DD-MON-YY')
         INTO v_time2
         FROM DUAL;
    
    -- follownig fails with ORA-00900: invalid sql statement .
       var_sql :=
             'BEGIN RESEND_MISSING_UFMS('''
          || v_time1
          || ' 04.00.00.000000000 AM'','''
          || v_time2
          || ' 04.00.00.000000000 AM'',''VPS''); END;';
       DBMS_OUTPUT.put_line (' Block :' || var_sql);
    
       EXECUTE IMMEDIATE var_sql;
    END;
    
  • Calling stored procedures with parameters with the database connectivity Toolkit

    Hi all

    I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work.  I have a database in which I tables and stored procedures with parameters.  Some of these stored procedures have input, output and return parameters.

    I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument

    Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table).  In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int not null), PN (nvarchar ((15), null) and NumMACAddresses (int, null).)  I have surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful.  I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step.  I then try to use the VI of parameter query create to call the stored procedure and set the parameters.  I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI?  I am also having some confusion during and after these steps as well.  I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert.  Also, I would be happy to provide more information that might be useful.

    Kind regards

    Jon

    Here's what I use to do this.  I think I had to change him create parameterized query VI for him to work.  There is a post on the forum about this somewhere.

  • Ask about UTL_FILE stored procedure

    Hello

    I tried to do an insert into a table which then triggers a stored procedure to write the data inserted into a text file. However, I have a few questions here in the stored procedure. Thanks for trying to help... [Insert-> table-> Trigger-> stored procedure-> text file]

    -The user will execute this sql

    -insert into tester.test_table values ("ab");

    CREATE TABLE TESTER. TEST_TABLE

    (

    LINECODE VARCHAR2 (2 BYTE)

    )

    -Just for test purpose

    CREATE TABLE TESTER. TEST_REC_TABLE

    (

    LINECODE VARCHAR2 (2 BYTE)

    )

    CREATE OR REPLACE TRIGGER TESTER. TRIGGER_AUDIT

    AFTER INSERT OR UPDATE

    TESTER MARKET. TEST_TABLE REFERENCING OLD AS OLD AGAIN AS NEW

    FOR EACH LINE

    DECLARE

    sLineCode VARCHAR2 (2);

    BEGIN

    sLineCode: = ";

    IF THE UPDATE CAN

    sLineCode: =: NEW. LINECODE;

    TRIGGER_PACKAGE. WRITE_FILE (sLineCode);

    END IF;

    IF THE INSERTION

    sLineCode: =: NEW. LineCode;

    TRIGGER_PACKAGE. WRITE_FILE (sLineCode);

    END IF;

    EXCEPTION

    WHEN other then null;

    END TRIGGER_AUDIT;

    /

    CREATE OR REPLACE PACKAGE BODY TESTER. TRIGGER_PACKAGE

    is

    procedure WRITE_FILE (in_LineCode in varchar2)

    is

    sLineCode varchar2 (2);

    v_FileHandle UTL_FILE. TYPE_DE_FICHIER;

    -a few checks for null input data

    Start

    If ((rtrim (in_LineCode) IS NULL) or (in_LineCode is nothing)) then

    sLineCode: = "XX";

    on the other

    sLineCode: = in_LineCode;          -> PROBLEM HERE?

    end if;

    If (length (sLineCode) > 2) can

    sLineCode: = substr (sLineCode, 1, 2);

    end if;

    Insert into TEST_REC_TABLE (LineCode) values (sLineCode); -Insert data to another table for the test

    RUN IMMEDIATELY 'CREATE OR REPLACE DIRECTORY FILEDIR AS | '''' || 'c:\' || '''';

    v_FileHandle: = UTL_FILE. FOPEN ('FILEDIR', 'Test_Table.txt', 'w'); -write in the text file in C:\Test_Table.txt

    UTL_FILE. Put_line (v_FileHandle, 'insert' | sLineCode |) ' @ ' || TO_CHAR(SYSDATE,'DD-MM-YYYY HH:MI:SS AM'));

    UTL_FILE. FCLOSE (v_FileHandle);

    exception

    When other then null;

    end;

    end TRIGGER_PACKAGE;

    /

    (1) the problem I encountered is that when I run sql INSERT for new data, it can be successfully be inserted in both tables TEST_REC_TABLE and table_test, but just do not write in the text file.

    (2) However, when I simply run the procedure I'll get XX for data entry because it is NULL. These data XX then will be seen in TEST_REC_TABLE in the folder "XX" and Test_Table.txt as "Inserted XX @ 01/10/2014-16:56:06. UTL_FILE wrote to textfile so my guess is that it could be due to my misunderstanding of the logic in the audit input null data. Tried, but I'm still distraught, thanks for reporting the issue.

    > 1) I'm just tests and I'm learning here with insert trigger...

    Good. In this case, it's just a bad choice that you have decided to write to a file of a trigger. Basic Oracle is a good site. They also have examples. Please check that the BASE ORACLE - overview of database triggers.

    (> 2) how do I do next?

    Simply create the object once

    CREATE OR REPLACE DIRECTORY FILEDIR AS

    The path must be a location on your server where oracle is installed.

    (> 3) how do I do next? Use this?

    EXCEPTION

    WHILE OTHERS THEN

    DBMS_OUTPUT. PUT_LINE

    ("ERROR" |) TO_CHAR (SQLCODE) | SQLERRM);

    NULL;

    Do not do something. Just remove the exception handling. Do not handle unknown exceptions. If all you want to manage the purpose of logging RECOVERY to end like that.

    exception

    while others then

    lift;

    And on one of the exceptions management forum, member BluShadow has written a nice article 101 PL/SQL: exception management. It would be an enjoyable read.

  • Multi-threading parallel processing of stored procedures

    Hi guys,.

    I have the following scenario, and I would like to realize parallel processing to increase the performance of data refresh:

    Stored procedure "SP1" - refresh table A
    Stored procedure 'SP2' - Update table B
    Stored procedure "SP3" - updates table C

    I would like to be able to update table A, B and C table at the same time, could someone help me identify ways in what could be achieved if something like this is possible?

    I use collections in stored procedures SP1, SP2 and SP3 to accelerate the time to refresh table, although would like to know how parallel update tables.

    I have briefly heard the dbms_pipe package, which would be useful in this scenario?

    Thank you
    Rohan

    rbha4 wrote:

    I use collections in stored procedures SP1, SP2 and SP3 to accelerate the time to refresh table, although would like to know how parallel update tables.

    As already mentioned - perform these distinct process procedures in planning jobs. DBMS_JOB and DBMS_SCHEDULER interfaces can be used. If the work queue manager supports (has been configured) with 3 or more processes working slots and these are empty and not used, then all the 3 procedures can be performed in parallel.

    This can be as simple as running the following anonymous block to schedule 3 jobs for immediate execution:

    declare
      jobID number;
    begin
      DBMS_JOB.Submit( jobID, 'procA;', sysdate );
      DBMS_JOB.Submit( jobID, 'procB;', sysdate );
      DBMS_JOB.Submit( jobID, 'procC;', sysdate );
      commit;
    end;
    

    I have briefly heard the dbms_pipe package, which would be useful in this scenario?

    Only when the IPC (Inter Process Communication) is required only if the database pipes best fits this requirement.

  • 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

  • using temporary Tables

    Hello

    I use a temporary table in my procedure to insert and select data. I used ON COMMIT PRESERVE ROWS option.but given in my temporary table are not deleted, even though I explicitly have a close connection to my ASP.NET page. So from now on I use delete (temporary table) to remove the data and insert the new set of records.
    I would like to know why this phenomenon occurs

    Kind regards

    Hello

    ODP.NET uses the default connection pool, so the connection is not actually closed when you call close/features in your application. This is a limitation of the layer OIC you cannot restore an existing connetion to the State 'blank '... That is to say, the packaging, temporary tables, etc.

    Unfortunately, this makes temporary tables a bit difficult to work with. You can either
    (1) use a transaction in your code odp.net rather than ON COMMIT PRESERVE ROWS to keep the data available until you're done with it, or
    (2) disable connection pool by setting Pooling = false in your connection string, or
    (3) explicitly clear the table do you.

    See you soon,.
    Greg

  • MySQL temporary tables or call Stored procedures in CS4

    I need to filter the results by username before making a LEFT JOIN and including lines or IS NULL. The SQL works from the mysqli client, either by creating a temporary table using the "create a temporary table temp_appts select * from...» "Or by creating a stored procedure that contains the statement even 'create temporary table' and then running my LEFT JOIN statement against the temporary table.

    I've tried both in CS4, it accepts the code 'code' without errors but the page loads in a browser as a white or a 500 error in Internet Explorer. From my experience, this is caused by the exit before arriving to the html header.

    Is it possible to do either in CS4?  Here is the code I use.

    $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 SELECT temp_appts * of 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!

    Why not just use a derived table, rather than creating a temporary table?

Maybe you are looking for