Updating a temporary table thru a procedure

Hi, let's say i have a reference table named LP_TEST.  From this table I get records and insert them into a temporary table named LP_TEMP.  After inserting the records, i run a procedure named CALC_AREA, which is used to update a certain column AREA in table LP_TEMP (putting values into the column AREA from NULL).  Inside my procedure CALC_AREA, i have a commit.  After running the procedure, I query the value of AREA from LP_TEMP table but it seemed that the column AREA was not updated.  However, i did the same exact thing but instead of using a temporary table, i used a regular table named LP_TEMP_TEST.  In this, table, i get an output for column AREA.
What is the problem with my temporary table?  I have ON_COMMIT, PRESERVE ROWS and NO_CACHE set on my temporary table.  Does update table in a procedure run on temporary tables?  I am using Form Builder 10.1.2.0.2.  Please help.  Thanks

Is your procedure by any chance declared as an autonomous transaction? Also are you 100% sure your update statement *really* updates data in your temp table? I'd fire up the debugger to make sure of that...
cheers

Similar Messages

  • Using temporary tables in stored procedures

    Suppose that I have created a temporary table in a stored procedure using an "EXECUTE IMMEDIATE" statement. When I compile the procedure, that table is not created yet, so the compiler says that the table does not exist.
    What is the way of using temporary tables in stored procedures?

    It's a good practice to avoid using DDL statements being executed from stored procedures. "Truncate Table" via dynamic SQL from stored procedure is a different story and is useful in DSS environments.
    But if you insist on "creating" tables using Dynamic SQL from Stored Procedures then you must also embed your DML statements in Dynamic SQL to avoid compilation errors.
    Example:
    Create or Replace Procedure Proc_TestDynamicSQL is
    Begin
    Execute Immediate 'Create table myTable as select * from user_tables' ;
    Execute Immediate 'Update myTable set table_name = ''Test'' ' ; --two single quotes before and after the string "Test"
    End;
    In this case, Oracle wouldn't care about the table references during compilation.

  • Problem with temporary table in stored procedure

    Hi,
    I have to execute a stored procedure in java , where the stored procedure has refcursor as out parameter and within the procedure the refcursor out parameter is populated from a temporary table
    when iam trying to get the resultset in my program iam getting the oracle error: ora-08103 object is no longer in use.
    I think this is becos the temporary table object is not available to my program
    can any one please help me

    I don't understand this part.
    Your procedure has "argSchemaName" as input parameter. Why do you have hardcoded owner name here in the cursor?
    >>
    CURSOR csrEligTables IS
    SELECT
    object_name
    FROM
    all_objects
    WHERE
    Owner = 'HI0XXX001'
    AND
    >>
    The anonymous block that you are running also has same owner name.

  • Temporary Tables in Stored Procedure

    Hi,
    I am writing a stored procedure that will get data from different sources and generates a spreadsheet finally. Initial select gets the basic data and following selects merges data.
    For this I have created a table in the database, I am populating data into that table using same procedure and finally selecting data from that table to generate spreadsheet.
    Now I am planning to use TEMPORARY table instead of creating table in database. Can anyone tell me where I can view samples for temp tables?
    Which one is the better option in performance wise?
    or
    can I handle the whole scenario with cursor? any examples?

    Hi,
    Why can't you use a regular table?
    Look up [Global Temporary|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_7002.htm#sthref7247] in the diocumentation, including the SQL*Language manual, for an alternative.
    "Temporary" applies only to the data. A Global Temporary Table is created once, and stays until you DROP it, the same as any other table.
    The data in the table is temporary. If you create the table saying "ON COMMIT PRESERVE ROWS" (which sounds appropriate, based on your description) the the data will automatically be deleted when you end the database session.
    All data in Global Temporary Tables is session-specific. If two (or more) people are using the same table at the same time, each will only see the data they inserted themselves; they will never see rows inserted by the other session.
    Almost anything you can do with a regular table you can do with a Global Temporary Table. In particular, DML (such as MERGE) and cursors work exactly as they do on other tables.

  • Use of global temporary tables in Procedures

    Hi
    I am using global temporary tables in the procedures. Loading data in the same table through many procedures. I am fetching the data from the global temporary table in PRO-C by a cursor. Will this degrade performance?
    Please help me..
    Thanks in Advance...

    Will this degrade performance?That depends... in comparison to what?
    Loading data into temporary tables will generally be more efficient than loading data into permanent tables because Oracle needs to do less to protect this data since it is inherently transient. On the other hand, loading the data into a table in the first place tends to be more expensive than alternatives like using a single SQL statement, a pipelined table function, or an in memory collection.
    Justin

  • Temporary Tables in Oracle

    Hi all,
    I am developing a .net application withe back end being oracle 10g. previously i worked with sql server 2005,2008 and i am new to oracle.
    i am working on a complex query which requiries, temporary table inside the procedure. In sql server easy to create and drop the temp table inside the proc.
    Can I use a Transaction specific GTT to store and process the temporary data inside my procedure??? My web application gets connected to the database through a one username and password. Since being a web applicatioin multiple users will execute the procedure at the same time, logged under the same username and password...
    I know its a coomon question, but i need it urgently..
    its very complicated to use WITH SELCT or inline views etc...
    Thank you,
    Kris.

    I know its a coomon question, but i need it urgently..If you know it is a common question then you should know the common answer. But let's rehearse it one more time.
    In Oracle temporary tables are permanent objects. It is only the data in them which is temporary. So for your scenario you shoudl have the DBA create the table once, like any other table.
    The trick with temporary tables is that each session sees its own data and nothing else. So your procedure can populate the table with data, process it and return it without a hitch.
    Since being a web applicatioin multiple users will execute the procedure at the same time, logged under the same username and password...Doesn't matter: the view of the data is controlled by session. So you haven't got a problem providing the table is populated and the resultset returned within a single call.
    its very complicated to use WITH SELCT or inline views etc...Yes it is hard. Fortunately CPUs keep getting more powerful and bandwidth keeps getting cheaper, so our systems continue to cope with the increasing amount of suck-y code being thrown at them. Isn't Moore's Law wonderful :)
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Inserting Data to a temporary table

    Hi,
    This may sound strange, but I see code that inserts data to a temporary table, which sources from the same temporary table. The code looks like this:
    -- Some code that initially inserts data to #tmpA
    IF(UserId = 0)
    BEGIN
    INSERT INTO #tmpA
    SELECT * from #tmpA
    END
    I'm just curious on how this code snippets would do. Would this end up to an infinite loop? The whole code runs endlessly, I don't know if it's because of the CURSOR that is being implemented, or is it because of this code snippets which probably inserts data
    to #tmpA endlessly?

    Hi KEARPEE,
    The code is really long, so I just emphasize on the area where I'm concern with.. it's something like that:
    -- Some code that declares variables. Some code that initially inserts data to #tmpA
    IF(@UserId = 0)
    BEGIN
    INSERT INTO #tmpA
    SELECT * from #tmpA
    END
    -- Some code that updates the temporary table, and display the result of the temporary table

  • How to update/query informix table for every update/query on Oracle table

    We have a system that can talk to only Oracle.
    Here, we have a certain program that updates an Oracle table thru a View of the Table. For every database operation on Oracle table View, we want to update a corresponding table in Informix database.
    Similarly for every query on the View of oracle table we want to query informix database and fetch the records from there.
    We want to use Oracle as a medium to access Informix.
    Can some one help me on how to do this ?
    Thanks

    You can use the Transparent Gateway for Informix to access Informix from an Oracle environment. The gateway makes the Informix database look like a remote Oracle database.
    You can take a look at the gateways page on OTN for more information on this. http://otn.oracle.com/products/gateways/content.html
    Look at the Certification matrix to ensure that you are using a certified configuration.

  • Can I use Parallel execution for Global Temporary table within SP and How

    Dear Gurus,
    I have Global temporary table as below
    Create global temporary table Temp_Emp
    empno number,
    ename varchar2(20),
    deptno number
    ) on commit preserve rows;
    During processing I insert the data into this table and then fire query on Temp_Emp, get the data and pass it to front end.
    The SP as shown below
    Create or replace procedure get_emp_data
    empid in number,
    emp_detail out RefCsr -- Ref cursor
    as
    begin
    -- some code here
    open emp_detail for
    select *
    from Temp_Emp
    where empno = empid;
    end get_emp_data;
    Can use Parallel Query execution on Temp_Emp table and how ?
    i.e. do need to explicitly use parallel construct in query or is it default.
    Because I have many SQL like above (on global temporary tables) within Stored Procedures.
    Can anybody give me any suggestion.
    Thanking in Advance
    Sanjeev

    How come you are populating a temporary table and then opening a cursor on this temporary table for the front end to use?
    Couldn't you presumably just form a query out of the code you use to populate the temporary table? This is the recommended approach in Oracle.

  • Query regarding updation thru a Procedure

    Hi,I have a query regarding updation.
    1.I invoke a procedure in Oracle called submit thru my Java application.
    The submit procedure saves the XML data in the database
    and displays this data in a Front End GUI.
    2. Now,I make a change in my Java application by adding new elements to the same row.This row now contains additional XML elements.
    I would like to display the new row with the new elements in the GUI.
    What is a better option for doing the above?
    1.Delete the row being shown,save the new row with the changes in the database,and re display it?
    2.Or,Update the row dynamically and refresh?
    Any suggestions
    Thanks,

    Hi,I have a query regarding updation.
    1.I invoke a procedure in Oracle called submit thru
    my Java application.
    The submit procedure saves the XML data in the
    database
    and displays this data in a Front End GUI.
    2. Now,I make a change in my Java application by
    adding new elements to the same row.This row now
    contains additional XML elements.
    I would like to display the new row with the new
    elements in the GUI.
    What is a better option for doing the above?
    1.Delete the row being shown,save the new row with
    the changes in the database,and re display it?
    2.Or,Update the row dynamically and refresh?
    Any suggestions
    Thanks,If you delete (it seems to me yours this process is regular and frequent) and re insert the new updated one record then High water mark will cause to scan yours table which may cause to degrade the performance.AFAIK you should go with update.But hold down dont implement it as i suggested lets see what are others solution here which may be more precious then mine.
    Khurram

  • Temporary table with in a stored procedure

    Hi:
    I am trying to create a SP with a temporary table, and getting a syntex error. Here is my code. Can someone help me on this ?
    Thank you,
    Dima
    create or replace procedure ACCEPT."HIROC_IBC_CLAIMS"(policy_no cm_pm_interface.policy_no%type
    ,EXPOSURE_UNIT coverage.EXPOSURE_UNIT%type
    as
    begin
    CREATE GLOBAL TEMPORARY TABLE HIROC_IBC_NUMBER_OF_BEDS
    POLICY_NUMBER VARCHAR2(100),
    NUMBER_OF_BEDS VARCHAR2(100)
    insert into HIROC_IBC_NUMBER_OF_BEDS(policy_no
    ,EXPOSURE_UNIT
    select POLICY_NO, SUM(EXPOSURE_UNIT)
    From coverage C, cm_pm_interface CIN
    WHERE C.COVERAGE_PK = CIN.COVERAGE_PK (+)
    AND CIN.COVG_TYPE = 'COVGCLASS'
    AND CIN.COVERAGE_CODE IN ('ACUTE')
    GROUP BY POLICY_NO
    end HIROC_IBC_CLAIMS;
    /

    At the end I want to get a out put similar to following SELECT script. But there are many tables involved to get the data based on the maximum data value, then some other case statements in the logic etc. I am doing in smaller steps in the query rather than creating a big query. I find it is very easy to follow and debug.
    (Ex: UPDATE MONTH_CLAIMS A SET NUMBER_OF_BEDS = (NUMBER_OF_BEDS - 1)
    WHERE TO_DATE(POLICY_EFFECTIVE_DATE, 'DD-MM-YYYY') < TO_DATE('01-01-2010', 'DD-MM-YYYY');
    --Final data set
    SELECT
    '110' || As Company_Number || 1-3 '110'
    TO_CHAR(ADD_MONTHS(LAST_DAY(SYSDATE),-1),'YYMM') ||-- As Entry_Date,--4-7 YYMM
    '4' || As Statistical_Plan ||--8
    TRANSACTION_TYPE_CODE || As Transaction_Type_Code,9
    '' || As Branch_Code, this is a blank field 10-12
    Policy_Number || As Policy_Number, 13-23
    TO_CHAR(policy_Effective_Date, 'YYMM') || As Policy_Effective_Date, YYMM 24-27
    '8601' || --As Retroactive_Date,
    claimnumber || --As claimnumber,
    TO_CHAR(Date_of_Loss, 'YYMMDD') || --As Date_of_Loss,
    TO_CHAR(Notice_of_Occurrence_Date, 'YYMM') || --As Notice_of_Occurrence_Date,
    '1' || --As Basis_of_Claim_Code,
    TO_CHAR(report_date, 'YYMM') || --As Report_Date,
    '999' || --As Loss_Control_Event_Code,
    '980' || --As Premium_Location_Code,
    '8061' || --As Industry_Classification_Code,
    '3' || --As Line_Code,
    '61' || --As Coverage_Policy_Form_Code,
    '6' || --As Policy_Type_Code,
    ExposureType || --As ExposureType,
    Exposure_Base_Unit || --As Exposure_Base_Unit,
    Number_Of_Beds || As Number_Of_Beds, 78-83
    Policy_Limit || -- As Policy_Limit,
    '100' || --As Precentage_Participation,
    Expense_Code || --As Expense_Code,
    ABS(TRANS_AMT) || --As Expense_Amount,
    '1' || --type code
    '0' --Unsigned deductible limit
    from MONTH_CLAIMS

  • Update query not working thru procedure

    Hi
    I need to update one table column based on another table column.
    thru sql statement it is working, but same statement is not working thru stored procedure.
    update target_table a set a.col2 = (select col2 from source_table b where a.id = b.id);
    Above statement is working thru sql statement ,but it is not working thru procedure.
    So Please on this.
    Regards,
    Venkat

    post the code for the procedure. Kindly use before and after the procedure statement!                                                                                                                                                                                       

  • How can i create a Global Temporary Table inside a Stored Procedure....

    Hi...
    I need to create a Global Temporary Table inside a Stored
    Procedure....
    I have no idea how to do that....
    Please....if u can send me a sample, send to me....
    Thanks a lot

    To create a global temporary table inside a stored procedure,
    the minimal syntax would be:
    CREATE OR REPLACE PROCEDURE procedure_name
    AS
    BEGIN
    EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE table_name'
    || '(column_name NUMBER)';
    END procedure_name;
    As Todd stated, it would probably be better to create the global
    temporary table outside of the procedure:
    SQL> CREATE GLOBAL TEMPORARY TABLE table_name
    2 (column_name NUMBER);
    Table created.
    You can also specify things like ON COMMIT PRESERVE ROWS or ON
    COMMIT DELETE ROWS.
    It may be that there is something else, like a PL/SQL table of
    records or a cursor, that would suit your needs better. It is
    difficult to guess without knowing what you want to do with it.

  • Global temporary table in a store procedure

    Hi,
    I REALLY need to create a global temporary table in a stored procedure but I don't know how .........
    My solution was
    create or replace procedure test(
    as
    begin
    execute immediate 'create global temporary table t(x number,..) ;';
    end;
    but the table is not created. What I am doing wrong and how to resolve the problem?
    Thanks.

    There is NO valid reason to create a GTT on the fly (except during installation of a package). This defeats the entire logic behind it. Precreate it and use it by a million users at the same time and it won't care. For more information On GTT's see.
    http://download-west.oracle.com/docs/cd/A87860_01/doc/appdev.817/a76939/adg03sch.htm#7807

  • Update Yes/No field in access table through oracle procedure

    Hi,
    How to update Yes/No field in access table through oracle procedure. all other fields like AutoNumber, Text I can update it. Yes/No field how to update? Please, any one can help me?
    Thanks and Regards,
    Sudha.

    Sudha Teki wrote:
    select "fldPost" from tblPHd@ODBCLNKNot quite sure what you mean, but the way you select the column would indicate a case sensitive column name
    Look at this example
    SQL> create table t
      2  ("this" varchar2(10))
      3  /
    Table created.
    SQL> insert into t values ('hello')
      2  /
    1 row created.
    SQL> select *
      2    from t
      3  /
    this
    hello
    SQL> select this
      2    from t
      3  /
    select this
    ERROR at line 1:
    ORA-00904: "THIS": invalid identifier
    SQL> select "this"
      2    from t
      3  /
    this
    helloIs your column name also case sensitive?

Maybe you are looking for