Problem ! Calling report6 from forms6(run_product()) using global temporary table.
Requirement :
To generate stock movement report for certain selected items.
Background :
A Form is created with data block (tmp_item_master - a global temporary table)
when_new_form_instance :
inserting into tmp_item_master from item_master and then execute_query on tmp_item_master block.
User selects certain items using check box provided.
Now tmp_item_master is updated for ch_select_flag_yn = 'Y' for selected items
and commit.
Calling report from form(using run_product()).
Now the main query in report, is joined with tmp_item_master where ch_select_flag_yn = 'Y'
Here, we are unable to see the report for any item. As the global temporary table data is not visible in the report session.
How to resolve this problem ?
Note : global temporary table created with ON COMMIT PRESERVE ROWS
Thanking you,
From praful.
null
Hi,
You are using 'ON Commit Delete Rows' . Instead of Use ' ON COMMIT PRESERVE ROWS'
The ON COMMIT DELETE ROWS clause indicates that the data should be deleted at the end of the transaction.
CREATE GLOBAL TEMPORARY TABLE my_temp_table (
column1 NUMBER,
column2 NUMBER
) ON COMMIT DELETE ROWS;
In contrast, the ON COMMIT PRESERVE ROWS clause indicates that rows should be preserved until the end of the session.
CREATE GLOBAL TEMPORARY TABLE my_temp_table (
column1 NUMBER,
column2 NUMBER
) ON COMMIT PRESERVE ROWS;
Edited by: Mrucha on Nov 26, 2012 6:06 AM
Similar Messages
-
When to use global temporary tables?
which are the probable situations when one can think of using global temporary tables?
In my experience, most often GTTs are used by developers from other RDBMSs who have become used to needing 'intermediate tables' created on the fly to hold data while they 'loop and commit to free locks'.
These developer may not have had enough exposure to Oracle's concurrency model and therefore use the 'other' concurrency model as the basis for an application port - usually followed up by a call to the forum for assistance in performance tuning. <g>
That said, legitimate uses for GTTs include staging or scrubbing table for data transport or preparation, eg: ETL into a warehouse, when the intermediate data is
a) reproducible (therefore does not need to be logged); and
b) the results of the intermediate operation, but not the source, are stored in permanent tables.
Some developers also use GTTs to hold the equivalent to a 'temporary materialized view' specifically for complex reporting purposes. -
Using Global Temporary Table in Discoverer.
Hi All
I am currently working on a Disco report, where I am initializing a package at the disco condition level which inserts data in to a Global Temporary Table.
The global temporary table will be having data based on the parameter entered by the user. But the problem occurs when we are trying to use the same GTT in the select statement as shown below. The desktop is not giving me the otuput but the GTT is getting populated with data.
see below
SELECT bla1,
bla2,
bla3
FROM GTT (global temp table)
WHERE 1= PACKAGE.FUNCTION(par1, par2, par3...) <- here we are trying to insert into GTT based on the paramenters passed.
Can you please suggest how this can be achieved. Or is there any way to trigger the insertion in to GTT other than the calling it in the condition level.
Thanks
ArunHi,
You cannot use a GTT like this because you cannot write and read from the GTT using a single SQL statement. You must either have the insert in a separate worksheet and tell the users to run this worksheet first, or you wrap it all up in a table function called from within a view. The table function can then insert and select from the GTT using two statements.
Which method is best depends on what you are trying to do and why you want to use a GTT.
Rod West -
Using Global Temporary Table in OBIEE 11
Hi,
THe requirement is to run a database function before the report runs. This Function accepts 5 parameters (Presentation Variable) and populates a GTT Global Temporary Table.
This GTT is configured in presentation Layer.
Issue:
1. Created a dummy report which returns only one row and called the fucntion using "Evaluate" in this.
2. Created 2nd report using GTT Columns.
All these 2 reports placed on dashboard and Presentation variable are set in the prompt. The first one runs correctly and populate the "Regular Table". Means when I create a regular table instead of GTT I can see the correct record. But if I change it to GTT then the data does not get populated in this table.
Any Inputs?
RegardsHI,
If you are using a GTT, you need to run the function which populates the GTT before OBI server executes the select query on that table.
In your case, the OBI server is executing the select query from the table before the data is populated in the table.
In order to force the BI server to run the query after the GTT is populated, you need to specify the condition in the connection pool settings under the connection scripts tab.
In the execute before query, enter your physical query which runs the function to populate the GTT.
Hope this helps !
Thanks,
Vineeth -
Java Error while Using GLobal Temporary Tables
Hi,
Am having a global temporary table in my application with ON COMMIT DELETE ROWS option.
I use it in a procedure to remove previous records, populate new ones and return a ref cursor
Am calling this procedure from a java bean. In this call, the procedure gets executed successfully but when i try to access the RefCursor Object, I get an SQL Exception that the object no longer exists.
Here are some inputs for reference:
My DB Call:
cstmt = myConn.prepareCall ("{ call MYPACKAGE.GTT_PROCEDURE(?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?)}");
My RefCursor Access:
rsRuleSet = (ResultSet)cstmt.getObject(11);
The SQLException:
java.sql.SQLException: ORA-08103: object no longer exists
Please note that the SQLException shown as per Java Stack trace is on the line with the RefCursor Access
If anybody has any idea, then do reply
Thanks in Advance,
PiyushA couple of thoughts...
Have you tried calling this procedure from PL/SQL to verify that the REF CURSOR returned is valid?
Is your Java application set to autocommit, or do handle transactions yourself. If the container is handling transactions, it may committing as soon as the stored procedure finishes running, which would clear your temp table.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Problem with global temporary table in Oracle 10g
Hi All,
I face a peculiar problem in Oracle 10g with respect to Global temporary table.
Have Oracle 10g version in Production and 11g version in UAT.
Table_
create global temporary table TT_TEMPGPSMANUAL
Col_1 VARCHAR2(50),
Col_2 VARCHAR2(500),
Col_3 VARCHAR2(50),
Col_4 VARCHAR2(50),
Col_5 VARCHAR2(15),
Col_6 VARCHAR2(20),
Col_7 VARCHAR2(250),
Col_8 VARCHAR2(20),
Col_9 VARCHAR2(15),
Col_10 VARCHAR2(20),
Flag NUMBER,
Col_11 INTEGER,
Col_12 VARCHAR2(50)
on commit preserve rows;So this should preserve the rows inserted into this table until the session ends.
Have a webpage in front-end where in turn, it opens another page (session is carried through) and a few rows will be inserted to this table from the webpage (through a function) on submit and the current page will be closed.
From the parent page, if I open the sub-page data inserted in the temporary table are held and displayed (another function to fetch the values in the Global Temp table).
The Problem in Oracle 10g (Production) is, this is not happening properly. When I close and open the sub-page, not every time I get the data stored i.e if I close and open the page 10 times, atelast 4 times the data is missed in the page (I am not getting values from temp table) randomly.
But this does not happen in UAT (which has Oracle 11g installed) as I get the data in the webpage consistently. After passing UAT, when we rolled out to Prod, getting this issue which we are unable to get what could be the reason.
It is very hard to debug using GTT dynamically in prod. It takes time to get Oracle 11g installed in Prod.
Can anyone suggest?
Regards
Deep935195 wrote:
Also, I am opening the sub-page from the parent page (through a hyperlink). Then in this case, Would session will be changed from parent to subpage? (I am not aware exactly and have the impression that, as the second page is a child, I guess it would take the same session).I'm not sure what "sub-page" or "parent page" means to you. If you're just linking from one page to another, "parent" and "child" don't really make sense since page A links to page B and B links to A quite frequently.
Assuming that you have to log in to access the site, it is likely that the two pages share the same middle tier application session. It is unlikely that the middle tier would hold the database session from the first request open waiting to see if the user eventually requested the second page. It is theoretically possible that you could code your middle tier this way but it is extremely unlikely that you would want to do so for a variety of reasons. So, when you say "would [the] session ... be changed", it is likely that the application session would be the same for both calls but that the database session would be different.
Justin -
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 -
How to use Oracle temporary table and verify if it exists
1. I got two errors on the following code.
ORA-06550: line 13, column 4:
PLS-00428: an INTO clause is expected in this SELECT statement
ORA-06550: line 17, column 3:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
2. Can I include this code in the create view statement?
Thanks ahead, I am new to oracle dev world.
===========================================================
DECLARE
l_count NUMBER;
BEGIN
select count(*)
into l_count
from all_tables
where table_name like 'TEMP_SHOW_STAFF_2%';
if l_count > 0 then
select * from TEMP_SHOW_STAFF_2;
else
create global temporary table TEMP_SHOW_STAFF_2
(employee_id Number,
last_name varchar(10),
first_name varchar(10),
salary_amount varchar(10))
on COMMIT delete rows;
end if;
END;The PL/SQL User's Guide will have much more information, but as a quick example (new_dept is an empty table with the same structure as the DEPT table in the SCOTT schema).
1 declare
2 -- Create the type & declare a variable of that type
3 type dept_arr_typ is table of dept%rowtype;
4 dept_arr dept_arr_typ;
5 begin
6 -- Populate the type in memory
7 select *
8 bulk collect into dept_arr
9 from dept;
10 -- Manipulate the data
11 for i in 1..dept_arr.count
12 loop
13 select 'foo'
14 into dept_arr(i).dname
15 from dual;
16 end loop;
17 -- Write the data back
18 for i in 1..dept_arr.count
19 loop
20 insert into new_dept( deptno, dname, loc )
21 values( dept_arr(i).deptno, dept_arr(i).dname, dept_arr(i).loc );
22 end loop;
23* end;
SCOTT @ nx102 Local> /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
SCOTT @ nx102 Local> select * from new_dept;
DEPTNO DNAME LOC
10 foo NEW YORK
20 foo DALLAS
30 foo CHICAGO
40 foo BOSTONOf course, for this sort of thing, we could do everything in a single SQL statement
INSERT INTO new_dept( deptno, dname, loc )
SELECT deptno, 'foo', loc
FROM dept;Collections can be handy if you need to apply a bit more conditional logic, though.
Justin -
Will Partitioning improve performance on Global Temporary Table
Dear Guru,
In one of complicated module I am using Global Temporary Table (GTT) for intermediate processing i.e. It will store required data in it but the rows of the data goes into 10,00,000 - 20,00,000.
Can Partitioning or Indexing on Global Temporary Table improve the performance?
Thanking in Advance
SanjeevSounds like an odd use of a GTT to me, but I'm sure there are valid reasons...
Presumably you are going to be processing all of these rows in some way? In which case I can't see how partitioning, even if it's possible (And I don't think it is) would help you.
Indexes - sure, that might help, but again, if you are reading all/most of these rows anyway they might not help or even get used.
Can you give a bit more detail about exactly what you are doing?
Edited by: Carlovski on Nov 24, 2010 12:51 PM -
Global temporary table in PL/SQL called from APEX page
I have a global temporary table in a PL/SQL procedure that is called from an APEX page.
The global temp table is populated with data as the procedure runs and then at the end of the procedure I do a create_collection_from_query_b to populate a collection with the data from the temp table. (I do this b/c it is much faster than creating the collection and doing an add_member for each row.)
The problem is that there are no commits in my procedure but I cannot get the bulk insert to work unless I define the temp table as on commit preserve rows.
Can anyone shed any light on this issue.
Thanks,
Andrewalamantia wrote:
My PL/SQL procedure is called from an after submit page process. Does that imply that there is a commit happening after that process is successful?Ultimately, yes.
If the process calls the PL/SQL procedure and the temp table is in the procedure, wouldn't the commit fire after all the PL/SQL code is complete which would be after the bulk insert from the temp table to my collection?Yes, but at any point in the procedure containing code like
:APEX_ITEM := ...or
select ... into :APEX_ITEM from ...or
my_procedure(p_in => ..., p_out => :APEX_ITEM, ...);or
apex_util.set_session_state(...);then APEX will commit whilst maintaining session state.
If you don't have any of these events in the procedure, then test to see if the commit is occurring in <tt>apex_collection.create_collection_from_query_b</tt> prior to creation of the collection. -
Problem calling simplebutton from library
Hi guys,
I'd like to ask for your assistance. I have a problem calling
SimpleButton from library. I already checked the Linkage:Export for
actionscript but still an error appear "Call to a possibly
undefined method OkBtn". I'm just wondering because this method
works on my MovieClips except for SimpleButtons. Is there another
way to call SimpleButtons?
Here's my code calling MovieClip:
var mc:MovieClip = new ourProduct();
and same in calling my SimpleButton:
var myOkBtn:SimpleButton = new OkBtn();
please help.
Thank you very muchHi again,
Since I could not call my SimpleButton inside the library, I
was thinking of putting my button inside the movieclip and call
that clip inside my library.
On my stage, I called
underConstructionPane() movieclip. This
underConstructionPane contains
myOkBtn which previously I wanted to call but as a work
around, I just put it inside
underConstructionPane movieclip with instance name of
okBtn. I added eventHandler on
okBtn which supposed to call
showHome() function outside
underConstructionPane.
showHome() was declared on the stage or root (I don't know
the correct term. hehehe
sorry.) but I don't know how to call that function.
I tried this:
var home = new showHome();
but it won't work.
Please help me
Thank you. -
What is the syntax for creating global temporary table using a select query
hii
I'm creating a global temporary table using a select query ..how to mention 'on commit preserve rows' that?
create global temporary table t1 as select * from trn_ordbase on commit preserve rows;
but this is invalid syntax,so how to mention on commit preserve rows in this???if i dont mention it ,by default its considering as on commit delete rows.
Please help me out of this problem.create global temporary table t1 as select * from trn_ordbase on commit preserve rows;You CANNOT use this syntax.
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/sqcmd.htm
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/glob_tab.gif
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/cre_tabl.gif -
Weird issue: Partial data inserted when reading from Global temporary table
I have a complex sql query that fetches 88k records. This query uses a global temporary table which is the replica of one of our permanent tables. When I do Create table..select... using this query it inserts only fewer records (66k or lesser). But when I make the query point to the permanent table it inserts all 88k records.
1. I tried running the select query separately using temp and perm table. Both retrieves 88k records.
2. From debugging I found that this problem occurred when we were trying to perform a left outer join on an inline view.
However this problem got resolved when I used the /*+ FIRST_ROWS */ hint.
From my limited oracle knowledge I assume that it is the problem with the query and how it is processed in the memory.
Can someone clarify what is happening behind the scenes and if there is a better solution?
Thanksuser3437160 wrote:
I have a complex sql query that fetches 88k records. This query uses a global temporary table which is the replica of one of our permanent tables. When I do Create table..select... using this query it inserts only fewer records (66k or lesser). But when I make the query point to the permanent table it inserts all 88k records.
1. I tried running the select query separately using temp and perm table. Both retrieves 88k records.
2. From debugging I found that this problem occurred when we were trying to perform a left outer join on an inline view.
However this problem got resolved when I used the /*+ FIRST_ROWS */ hint.
From my limited oracle knowledge I assume that it is the problem with the query and how it is processed in the memory.
Can someone clarify what is happening behind the scenes and if there is a better solution?
Thanksmight specifics be OS & Oracle version dependent?
How to ask question
SQL and PL/SQL FAQ -
Use global temp table for DML error logging
our database is 11.2.0.4 enterprise edition on solaris 10
we are wondering if anyone has an opinion of or has done this before, to use a global temp table for DML error logging. We have a fairly busy transactional database with 2 hot tables for inserts. The regular error table created with dbms_errlog has caused many deadlocks which we don't quite understand yet. we have thought using global temp table for the purpose, and that seemed to work, but we can't read error from the GTT, the table is empty even reading from the same session as inserts. Does anyone have an idea why?
ThanksThe insert into the error logging table is done with a recursive transaction therefore it's private from your session which is doing the actual insert.
Adapted from http://oracle-base.com/articles/10g/dml-error-logging-10gr2.php
INSERT INTO dest
SELECT *
FROM source
LOG ERRORS INTO err$_dest ('INSERT') REJECT LIMIT UNLIMITED;
99,998 rows inserted.
select count(*) from dest;
COUNT(*)
99998
SELECT *
FROM err$_dest
WHERE ora_err_tag$ = 'INSERT';
1400 "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")" I INSERT 1000 Description for 1000
1400 "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")" I INSERT 10000 Description for 10000
1400 "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")" I INSERT 1000 Description for 1000
1400 "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")" I INSERT 10000 Description for 10000
rollback;
select count(*) from dest;
COUNT(*)
0
SELECT *
FROM err$_dest
WHERE ora_err_tag$ = 'INSERT';
1400 "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")" I INSERT 1000 Description for 1000
1400 "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")" I INSERT 10000 Description for 10000
1400 "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")" I INSERT 1000 Description for 1000
1400 "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")" I INSERT 10000 Description for 10000 -
Use Global Temp Table to overcome Mutating Trigger issue
Hello all. I need to delete a line in a table, and thought I would get around the mutating trigger issue by creating a GTB table. I created 2 different triggers. One is a Row level trigger, the other a Statement level trigger.
The first trigger gathers the information I need to identify the line I want to delete. This is:
CREATE OR REPLACE TRIGGER Requisition_Capture
AFTER UPDATE OF Delivery_Code on Supply_Items
FOR EACH ROW
BEGIN
IF :NEW.Delivery_Code = '#' THEN
INSERT INTO Requisition_Storage
(Req_Code)
VALUES
(:NEW.Requisition_Code);
END IF;
END;And the second trigger deletes the line:
CREATE OR REPLACE TRIGGER SUPPLY_ITEM_RESET
AFTER INSERT ON Requisition_Storage
DECLARE
BEGIN
DELETE FROM Supply_Items r
WHERE r.Requisition_Code =
(SELECT t.Req_Code
FROM Requisition_Storage t, Supply_Items s
WHERE t.Req_Code = s.Requisition_Code)
AND r.Order_Qty = 0;
END;The GTB is as follows stores the information I need to delete the line.:
-- Create table
create global temporary table REQUISITION_STORAGE
req_code VARCHAR2(20)
on commit delete rows;When the column Delivery_Code is updated in the Supply_Item table, and the value is reset to '#', I want to capture the Requisition_Code in the GTB, so I can run the statement level trigger and delete the reset row. However, I still have a mutating error problem. What am I missing?The statement level trigger would need to be an AFTER UPDATE OF Supply_Items for this to work around the mutating trigger issue. You need to ensure that your UPDATE has finished updating all the rows that it is going to update before your statement-level trigger runs.
As has been pointed out, however, the desire to work around a mutating trigger error almost always indicates that you have a data model problem. And you're almost always better served by fixing the data model than working around the error.
Justin
Maybe you are looking for
-
Business Catalyst changes for the worst
I just have to say that I am getting really frustrated with the changes going on with Business Catalyst at the moment. Here are a few things I am finding really frustrating. Does anyone else feel the same? What happened to the www.businesscatalyst.co
-
J1INQEFILE - efile generation - Exported file shows Duplicate records.
Dear Team, When I execute J1INQEFILE, I am facing problem with the e-file generation i.e. exported Excel file. When I execute and export the file in excel to the desktop, I can see duplicate records. For eg. On execution of J1INQEFILE, I can see 4 re
-
Dear All, We have designed a smart form for printing of excise invoice. The invoice is in two pages. The second page printing is not aligned and starts immediately after the finish of the 1st page. There is no buffer place between two pages. How can
-
Using Basic Template, Title in Huge Letters
I'm using the Basic template. The cover's fine. But once I put in a page, in this case a main title (same thing with a half-title), when I open it in the iBooks app on my iMac, I see the cover. Next it moves to thumbnails across the bottom and rather
-
Applications Browser Logon & Connection Refused & Cannot reconnect to gatew
Help, When running applications logon http://bh001.home:8000/OA_HTML/AppsLocalLogin.jsp I recieve a connection refused error. Associated with this is the following when running "adstrtal.sh APPLSYS/APPS" are the following errors =====================