Global Temporary Table not deleting Rows
why is my Global temp table not deleting the rows after commit see below,
CREATE GLOBAL TEMPORARY T_CHG
TBE VARCHAR2(7),
ABC VARCHAR2(8),
EFDA VARCHAR2(6),
ABD VARCHAR2(9),
A_ID VARCHAR2(128),
C_DATE,
ON COMMIT DELETE ROWS;
Quite a few syntax issues with your create statement. It would have helped if you had posted a SQL*Plus session showing your results. Here is mine which works just fine:
sql>create global temporary table t_chg
2 (
3 tbe varchar2(7),
4 abc varchar2(8),
5 efda varchar2(6),
6 abd varchar2(9),
7 a_id varchar2(128),
8 c_date date
9 )
10 on commit delete rows;
Table created.
sql>insert into t_chg values ('1', '2', '3', '4', '5', sysdate);
1 row created.
sql>select count(*) from t_chg;
COUNT(*)
1
1 row selected.
sql>commit;
Commit complete.
sql>select count(*) from t_chg;
COUNT(*)
0
1 row selected.
Similar Messages
-
Create global temporary table in delete trigger
Hi to all, I am triyng to create a global temporary table in trigger so i can hold all the deleted rows and do some stuff after the statement which uses the table that fires the trigger.
In this way I am trying to avod mutating table error. but the following trigger gives error.
create or replace
TRIGGER TD_EKSINAVLAR
FOR DELETE ON DERSSECIMI_EKSINAVLAR
COMPOUND TRIGGER
BEFORE STATEMENT IS
BEGIN
CREATE GLOBAL TEMPORARY TABLE DELETED_ROWS
AS ( SELECT * FROM DERSSECIMI_EKSINAVLAR WHERE 1 = 2 )
ON COMMIT DELETE ROWS;
END BEFORE STATEMENT;
BEFORE EACH ROW IS
BEGIN
NULL;
END BEFORE EACH ROW;
AFTER EACH ROW IS
BEGIN
NULL;
END AFTER EACH ROW;
AFTER STATEMENT IS
BEGIN
NULL;
END AFTER STATEMENT;
END TD_EKSINAVLAR;
the error is
Error(12,5): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: ( begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
Please help me about the situation.
Thanks in advance.
GokhanKarthick you are absolutly right
Our main process is to migrate sql server 2000 database to oracle 11g and I am stuck with the triggers that reference to table that fires the trigger itself.
Can you help me about how i can overcome mutating table errors using compund triggers? Espacially for the situation that one statement tries to update or delete multiple rows on a table.
You can understand my logic from the above code. I want to hold all the affected rows in a table and in after statement body using a cursor on that table I want to do required changes on the table. How can I do that or how should I do ?
regards. -
Inserts into Global Temporary Table
I'm working on using a global temporary table in one of my apps. I have a small test run here to isolate the problem. It simply creates the global temporary table, inserts a row, commits and then does a select to see if the insert worked. No data shows in the table when running this. I don't know much about global temp tables, so any help would be appreciated.
CREATE GLOBAL TEMPORARY TABLE AGENT_SILO.AS_TEMP_VALIDATE (
SBI_EMPLOYEE_ID NUMBER,
CURRENT_FLAG char(1),
EFFECTIVE_START date,
EFFECTIVE_END date
) ON COMMIT DELETE ROWS;
INSERT INTO AGENT_SILO.AS_TEMP_VALIDATE(SBI_EMPLOYEE_ID, CURRENT_FLAG, EFFECTIVE_START, EFFECTIVE_END)
VALUES(0, '', SYSDATE, SYSDATE);
commit;
SELECT * FROM AGENT_SILO.AS_TEMP_VALIDATE;So I wonder what else I'm doing wrong that's really obvious. Here's what i'm trying to accomplish and maybe there's a better way of going about it.
I have a trigger that is supposed to do some validation before the insert is allowed to go through. So here's my approach. I have a trigger fired when there's an insert into the AS_Employee_history table. This passes some of the fields from this insert into a proc (the id, a flag and a couple of dates). Within the proc, i create a global temp table, insert these passed values into the temp table. Then I have a cursor to basically copy the rows from the as_employee_history table that have the same id. Then I can do some selects on the temp table to see if it passes the validation.
I have outputs throughout for debugging and it gets to right after the inserts into the temp table, then the rest of the code doesn't appear to be executed. So it looks like it's failing at the execution of select statements on the temp table. Anything else obvious that I"m missing here?
Here's my proc.
PROCEDURE "PAS_VALIDATE" (STATUS OUT VARCHAR2, v_status OUT BOOLEAN, NEW_SBI_EMPLOYEE_ID IN NUMBER,
NEW_CURRENT_FLAG IN CHAR, NEW_EFFECTIVE_START IN DATE,
NEW_EFFECTIVE_END IN DATE)
IS
v_prev_effective_end date;
v_flag_count number;
v_flag_count_date number;
--variables to store dynamic sql returns
v_sql_flag_count_date varchar2(255);
v_sql_flag_count varchar2(255);
v_sql_prev_eff_end varchar2(255);
cursor c_row is
select * from AGENT_SILO.AS_EMPLOYEE_HISTORY EMP
where (EMP.SBI_EMPLOYEE_ID = NEW_SBI_EMPLOYEE_ID);
r_row c_row%ROWTYPE;
BEGIN
Status := 'Started';
v_status := true;
DBMS_OUTPUT.PUT_LINE('Creating temporary table...');
execute immediate 'CREATE GLOBAL TEMPORARY TABLE AGENT_SILO.AS_TEMP_VALIDATE (
SBI_EMPLOYEE_ID NUMBER,
CURRENT_FLAG char(1),
EFFECTIVE_START date,
EFFECTIVE_END date
) ON COMMIT PRESERVE ROWS';
DBMS_OUTPUT.PUT_LINE('Validating the data...');
--DBMS_OUTPUT.PUT_LINE('Inserting submitted row into temp table');
--Insert the new row being submitted from user into the temp table
execute immediate 'INSERT INTO AGENT_SILO.AS_TEMP_VALIDATE(SBI_EMPLOYEE_ID, CURRENT_FLAG, EFFECTIVE_START, EFFECTIVE_END)
VALUES(' || NEW_SBI_EMPLOYEE_ID || ',
''' || NEW_CURRENT_FLAG || ''',
to_date(''' || to_char(NEW_EFFECTIVE_START, 'mm/dd/yyyy hh:mi:ss') || ''', ''mm/dd/yyyy hh:mi:ss''),
to_date(''' || to_char(NEW_EFFECTIVE_END, 'mm/dd/yyyy hh:mi:ss') || ''', ''mm/dd/yyyy hh:mi:ss''))';
--Insert the other rows to we end up with a subset of the employee history table
--with only rows that match the sbi_employee_id of the submitted row
--DBMS_OUTPUT.PUT_LINE('Inserting into temp table...');
open c_row;
loop
fetch c_row into r_row;
exit when c_row%NOTFOUND;
execute immediate 'INSERT INTO AGENT_SILO.AS_TEMP_VALIDATE(SBI_EMPLOYEE_ID, CURRENT_FLAG, EFFECTIVE_START, EFFECTIVE_END)
VALUES(' || r_row.SBI_EMPLOYEE_ID || ',
''' || r_row.CURRENT_FLAG || ''',
to_date(''' || to_char(r_row.EFFECTIVE_START, 'mm/dd/yyyy hh:mi:ss') || ''', ''mm/dd/yyyy hh:mi:ss''),
to_date(''' || to_char(r_row.EFFECTIVE_END, 'mm/dd/yyyy hh:mi:ss') || ''', ''mm/dd/yyyy hh:mi:ss''))';
end loop;
close c_row;
DBMS_OUTPUT.PUT_LINE('After inserts');
-----Store queries to determine values for validation--------------------------
v_sql_prev_eff_end := 'SELECT to_char(max(effective_end), ''dd-mon-yy'')
FROM AGENT_SILO.AS_TEMP_VALIDATE
where to_char(EFFECTIVE_END, ''dd-mon-yy'') != ''31-dec-99'' AND
SBI_EMPLOYEE_ID = NEW_SBI_EMPLOYEE_ID';
--Find the largest effective_end, besides the 9999 value
execute immediate v_sql_prev_eff_end into v_prev_effective_end;
DBMS_OUTPUT.PUT_LINE('The highest previous end date: ' || v_prev_effective_end);
--...........Validation testing...........
execute immediate 'DROP TABLE AGENT_SILO.AS_TEMP_VALIDATE'; --Drop temp table
DBMS_OUTPUT.PUT_LINE('Validation Procedure Complete');
COMMIT;
status:='Success';
EXCEPTION
When Others Then
ROLLBACK;
Status := SQLERRM;
END;
Thanks a bunch for helping a noob out. -
Auditing data from global temporary table
Hi I have a process that uses a global temporary table.
What it does it serve a consolidation point to merge a lot of data.
Some the former designer decides to use a global temporary table and the row will be gone once it got commit.
However, the data is corrupted occasionally. And ideally we would like to fix the upstream source data but this is too complicated and not feasible.
So we decide to audit the data going into the global temporary table. We want to generate a report on the corrupted data.
However, whenever I commit, the data is gone from the global temporary table and we do not want to set it to commit preserve rows for the global temporary table
Even with autonomous transaction this is not working out as once it commits the data is gone.
Any idea how this can be done. Here are the prototype that I build to demo this:
drop table gt_tst1;
--this is the table its data needs to get audit
create global temporary table gt_tst1(id number); --on commit preserve rows;
drop table not_gt_tst1;
--this table is used for storign the corrupt data and generate report
create table not_gt_tst1 as select * from gt_tst1;
CREATE OR REPLACE PROCEDURE tst_gt_tst1 IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
--if there is a way to do the insert and select once. but it seems it is not working for global temporay table unless change it to on commit preserve rows
INSERT
when m2 = 0 THEN
INTO not_gt_tst1(id)values(object_id)
when m3 = 0 THEN
INTO gt_tst1(id) values (object_id)
select object_id,mod(object_id,2) m2, mod(object_id,3) m3 from dba_objects where rownum < 101;
COMMIT;
END tst_gt_tst1;
select sysdate from dual;
truncate table gt_tst1;
truncate table not_gt_tst1;
select * from gt_tst1;
select * from not_gt_tst1;
execute tst_gt_tst1;
select * from gt_tst1; -- data gone
select * from not_gt_tst1;
--commit
select sysdate from dual;
spool offThe data is poor and the code is poor and the dev and QA env is also poor..
And the business asks us to fix the data..However..we do not have an environment close enough to test it out before it got put into production that is the bottom line.
Heres the dev and QA env cannot be trust to the extent that I can sign off and say it will give the same behavior as the production env
So we would like to minimize the risk as there are other process uses these table and we are not sure if changing this would lead to UN-expected behavior.
We cannot tell some other process rely on the fact that these table got empty out after commit.
Edited by: vxwo0owxv on Jan 23, 2012 12:18 PM
Edited by: vxwo0owxv on Jan 23, 2012 12:20 PM -
Temporary Table Not Creating With Rows
I'm running Oracle 9i on Windows XP, and I'm trying to create a temporary table to use in a larger query. The problem is that when I create it using ON COMMIT DELETE ROWS, after creation it has no rows. If I use ON COMMIT PRESERVE ROWS, then I can't delete it unless I log out and come back.
Here's the query
CREATE GLOBAL TEMPORARY TABLE tempaltid
ON COMMIT PRESERVE ROWS as (select distributionid
from distributions d
where D.distributionid not in
(select distributionid
from distributionalternatives
where ( distributionalternatives.alternativeid not in (11018,11019,11020,11021,11022,11023,11024,
11025,11026,11475,11476,11477,11478,11479,
11480,11481,11482,11483,11484,11485,11486,
11487,11488,11489,11490,11491,11492,11493,
11494,11495)))
and D.distributiontypeid in
(239,209)
and D.distributionexpdt is null);
I'm not committing after creation, so I don't see why the table would just be empty.Yes you are, and before too
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm#sthref3520
You don't use global temporary tables like that, you create them once and fill and empty them repeatedly. -
Performance slow on DELETE command on global temporary table!
Hi,
I have a delete on a global temporary table that is taking long time!.
Anyone have a clue about how to improve delete command's against global temporary table??
Tks,
Paulo PortugalSame problem here!
<QUOTE>
SELECT DISTINCT PDT_CHILD.SUP_ID, PDT_CHILD.SUB_ID,
PDT_CHILD.SUB_LEAF_FLAG_ID
FROM
PJI_FP_AGGR_RBS_T PDT_CHILD WHERE 1=1 AND PDT_CHILD.SUP_ID = :B2 AND
PDT_CHILD.SUP_ID <> PDT_CHILD.SUB_ID AND PDT_CHILD.WORKER_ID = :B1
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 88561 20.71 20.23 0 0 0 0
Fetch 90269 926.19 906.80 45 45164134 0 176545
total 178831 946.91 927.03 45 45164134 0 176545
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 173 (APPS) (recursive depth: 1)
Rows Execution Plan
0 SELECT STATEMENT MODE: ALL_ROWS
0 HASH (UNIQUE)
0 TABLE ACCESS (FULL) OF 'PJI_FP_AGGR_RBS_T' (TABLE (TEMP))
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
latch: row cache objects 1 0.00 0.00
direct path write temp 3 0.00 0.00
direct path read temp 3 0.00 0.00
</QUOTE>
The fetch is too high for TEMP table... Any help would be much appreciated!
Note: Please teach me on how we can format the above in my future posts in OTN forums.
=== -
Global Temporary table is Not working For Pdf Reports
Hi all
we are using oracle db-10g, developer suite-10g.
While generating the Report for the satisfying several conditions we are fetching the data into
Global temporary table
On commit preserve rows
from this temp tables excel is generated properly. but pdf is not generating can anybody exaplain why it is not generating and what to do for that
Thank youquery and view are not possible
here i am giving one of the requirement
my project is belongs to inventory project.
report should be generated on the different selection criteria like
1)user can select one or more product codes
2)for that product code one or more item codes can select
like this so many different selection are there more than 12 selections from different tables
For this each different selection product code into gtt_prod_cd and item_cd into gtt_item_cd. after that performed the query and in where clause we are comparing the values with gtt.
can you please suggest me what to do for PDF Reports -
Problem with global temporary table with rows
Scenario :
I need to create a table for generating a report in a oracle 10g database. Data population in the table depends on the parameter passed from front end.
I have created global temporay table to achieve this. But use of same table by another user is not possible.
I have created the global temporary table as follows:
''Create global temporay table xyz (a varchar2(10),b varchar2(10)) on commit preserve rows''You have not posted much details.
But yes, global temporary tables are session specific. So other session won't see anything.
Amardeep Sidhu
http://amardeepsidhu.com/blog
http://oracleadmins.wordpress.com -
Datas deletion from Global Temporary table when clear command is given
Dear All,
How to Delete datas from global temporary Table when clear command is given in forms
Suggest me syntax..
Pls help..
Regards,
Gokul.Bhttp://psoug.org/reference/gtt.html
Francois -
Life time of data in a Global Temporary Table.
Dear Friends,
I have a global temporary table in which I insert some values via a backend package, when forms start up and accessing it via the same package when user performs some changes in it - storing the value and during exit saving it in the master table. My problem is the data is not accessible while processing. I'm using Oracle9i Enterprise Edition Release 9.2.0.1.0 database and Forms [32 Bit] Version 6.0.8.8.0. I also give you the script in using which I created the temporary table.
CREATE GLOBAL TEMPORARY TABLE GTT_PRA
A1 VARCHAR2(10 BYTE) NOT NULL,
A2 VARCHAR2(15 BYTE) NOT NULL,
A3 VARCHAR2(10 BYTE) NOT NULL
ON COMMIT DELETE ROWS;
Why is that so? Please help me.
With Regards,
Senthil .A. Perumal.Dear Arun,
Thank you for your script. But I'm accessing a large table, so for each and every process, the table get populated and grows very large giving some space problem, that is why I'm deleting rows when commiting. I would appreciate your help.
Dear Yogesh,
From the same forms I'm calling the backend package - will that be a different session. Once I'm calling to populate the table and next time I'm calling to store the user modified data and finally calling to store the data to master table. I think all are in the same sessions. Please reply me.
Thank you dear friends fr your immediate response. I would really appreciate it.
Regards,
Senthil .A. Perumal. -
ORA-00955 reports when I try to "create global temporary table" in windows
Hi,
When I try to run the sql in my oracle 9i server which is installed in a windows2000 machine,
Create global temporary table test ...;
For the first time, I can create table successfully.
But I cannot access this table any more:
drop table test;
desc test;
select * from test;
In addition, if I try to create the table again, I got the error:
ORA-00955: name is already used by an existing object
While the same table can be created and dropped in another oracle9i server which is installed in Solaris 9 machine.
So I suspect that this sould be a bug of window oracle server.
Is there anyone who can confirm this?
Or who can tell me how to report this bug to oracle?
Thanks in advance.
Please also refer the message at:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1046974576560
If you search the text: "create global temporary table sess_event", you can see for the first time, the table is created successfully.
But the ORA-00955 reports when the author try to create table for the second time.
This problem is exactly the same as my problem.
I have also made a search both in Google and in Oracle website and I cannot find any solution of it.Read Metalink Note:68098.1 Subject: Overview of Temporary Tables
How did you difine the temporary tables? on commit delete rows are reserv rows?
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg03sch.htm#7794
Jaffar
Message was edited by:
The Human Fly -
Doubt with Global Temporary table
hi,
i have created a global temporary table with ON COMMIT DELETE ROWS option. in my Function in a loop i m inserting values into this Table, after that loop closes and then i m selecting some other values from DB. and in the last i am returning a ref cursor which is selecting values from temporary table i hav created.
now the thing is i m not getting any values in the cursor.
later I have created the table with ON COMMIT PRESERVE ROWS option, in this case cursor returning values,
can anyone explain me the functionality, as per my knowledge global temporary table values are session specific so why i m not getting the values in the 1st case when i used ON COMMIT DELETE ROWS (same session).
Thanks
PiyushOk, here's a simple example, like we'd like to see from you not working....
First create a GTT with ON COMMIT DELETE ROWS...
SQL> ed
Wrote file afiedt.buf
1* create global temporary table mytable (x number) on commit delete rows
SQL> /
Table created.Now a simple function that populates the GTT and returns a ref cursor to the data without doing any commits (hence the data should be there!)
SQL> ed
Wrote file afiedt.buf
1 create or replace function pop_table return sys_refcursor is
2 v_rc sys_refcursor;
3 begin
4 insert into mytable
5 select rownum from dual connect by rownum <= 10;
6 OPEN v_rc FOR SELECT x FROM mytable;
7 RETURN v_rc;
8* end;
SQL> /
Function created.So now we call the function and get a reference to our ref cursor...
SQL> var v_a refcursor;
SQL> exec :v_a := pop_table();
PL/SQL procedure successfully completed.So, in principle, because no commits have been issued the ref cursor should return data...
SQL> print v_a;
X
1
2
3
4
5
6
7
8
9
10
10 rows selected.... which it does.
Now, what happens if we do that again...
SQL> commit;
Commit complete.
SQL> exec :v_a := pop_table();
PL/SQL procedure successfully completed.... but this time we commit before retrieving the data...
SQL> commit;
Commit complete.
SQL> print v_a;
ERROR:
ORA-00600: internal error code, arguments: [kcbz_check_objd_typ_1], [0], [0], [1], [], [], [], []
no rows selected
SQL>Oracle has (correctly) lost reference to the data because of the commit.
So show us what yours is doing. -
What to fill in "temp table scope" for global temporary tables?
Hi,
I'm using Data Modeler 4.0.1.836 and whatever I put in the "temp table scope" box for a global temporary table doesn't seem to affect the DDL script regarding the ON COMMIT PRESERVE/DELETE ROWS option. The script always shows ON COMMIT PRESERVE ROWS no matter what.
Yet, some of my temporary tables must be created as ON COMMIT DELETE ROWS.
The Data Modeler help says the following about this :
Temp Table Scope:
For a table classified as Temporary, you can specify a scope, such as Session or Dimension.
Not sure what "Dimension" has to do with the scope here, but it doesn't make any difference.
I tried putting "Session", "Dimension", "Transaction", but no luck. So what's the text to put for the script to generate ON COMMIT DELETE ROWS?
ThanksHi,
The Temporary Table Scope property (on the Classification Types page of the Table Properties dialog) is purely documentary.
To set ON COMMIT DELETE ROWS you should expand the Browser node for the Relational Model and look for the node for the relevant Oracle Physical Model. If you expand this you will find an entry there for your Table. Double-click on this to get the Physical Model properties dialog for your table, and you will find a "Temporary" property which has options YES (Preserve Rows), YES (Delete Rows) or NO.
David -
How can i write the trigger for Global Temporary Table
Hi Grus,
How can i write the trigger for Global Temporary Table.
I was created the GTT with trigger using the below script .
CREATE GLOBAL TEMPORARY TABLE GLOBAL_TEMP
EMP_C_NAME VARCHAR2(20 BYTE)
ON COMMIT PRESERVE ROWS;
CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
BEFORE DELETE OR UPDATE OR INSERT
ON GLOBAL_TEMP
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
INSERT INTO EMPNAME VALUES (:OLD.EMP_C_NAME);
END;
trigger was create successfully, but the wouldn't insert into to EMPNAME Table..
Please guide whether am correct or not? if not kindly give a correct syntax with example
Thanks in Advance,
Arun M MBEGIN
INSERT INTO EMPNAME VALUES (:OLD.EMP_C_NAME);
END;
you are referencing old value in insert stmt.
BEGIN
INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
END;then run ur application it works fine...
CREATE GLOBAL TEMPORARY TABLE GLOBAL_TEMP
EMP_C_NAME VARCHAR2(20 BYTE)
ON COMMIT PRESERVE ROWS;
CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
BEFORE DELETE OR UPDATE OR INSERT
ON GLOBAL_TEMP
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
dbms_output.put_line(:OLD.EMP_C_NAME||'yahoo');
INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
dbms_output.put_line(:OLD.EMP_C_NAME);
END;
create table EMPNAME as select * from GLOBAL_TEMP where 1=2
insert into GLOBAL_TEMP values('fgfdgd');
commit;
select * from GLOBAL_TEMP;
select * from EMPNAME;
output:
1 rows inserted
commit succeeded.
EMP_C_NAME
fgfdgd
1 rows selected
EMP_C_NAME
fgfdgd
1 rows selectedgot it Arun
Edited by: OraclePLSQL on Dec 28, 2010 6:07 PM -
Are global temporary tables in Oracle 10.2 behaving differently?
My procedure is creating and inserting data into a Global Temporary Table (on commit data is preserved). I am running this procedure in two different environments.
The first environment is running under Oracle 10.2 and after the procedure runs successfully I can not see any data inserted in the GTT.
When I run the very same procedure in the second environment which runs under Oracle 9.2, it works fine, runs successfully and I can see all rows inserted in the GTT.
Can someone explain this? What should I do differently in the Oracle 10.2? Any thoughts?
Thank you very much.Hi,
The following TEMPORARY table is created with the attribute, ON COMMIT DELETE ROWS. This allows an application to load registration entries into the global temporary table and manipulate that data with SQL statements. The data is deleted upon each commit with the clause ON COMMIT DELETE ROWS.
CREATE GLOBAL TEMPORARY TABLE student_reg_entries
student_name VARCHAR2(30),
reg_entries reg_entry_varray_type
) ON COMMIT DELETE ROWS;
Replace ON COMMIT DELETE ROWS with ON COMMIT PRESERVE ROWS to retain temporary table data throughout the database session, regardless of any commits made during that session.
The following illustrates a PL/SQL block that populates this temporary table with two classes each for two students. It makes no difference how many other applications are currently using this temporary global table for similar purposes. For the code below, two rows are inserted, then a COMMIT, after which a SELECT shows that the table is empty.
DECLARE
classes_to_take reg_entry_varray_type :=
reg_entry_varray_type();
BEGIN
classes_to_take := reg_entry_varray_type(
reg_entry('CS101', 'C' ),
reg_entry('HST310', 'C' ));
INSERT INTO student_reg_entries VALUES
('John', classes_to_take);
classes_to_take := reg_entry_varray_type(
reg_entry('ENG102', 'C' ),
reg_entry('BIO201', 'C' ));
INSERT INTO student_reg_entries VALUES
('Mary', classes_to_take);
END;
This next SELECT returns two rows:
SQL> SELECT * FROM student_reg_entries;
Row 1:
John
REG_ENTRY_VARRAY_TYPE
(REG_ENTRY('CS101','C'), REG_ENTRY('HST310','C'))
Row 2:
Mary
REG_ENTRY_VARRAY_TYPE
(REG_ENTRY('ENG102','C'), REG_ENTRY('BIO201','C'))
A COMMIT automatically deletes rows making the table available for the next session transaction.
SQL> COMMIT;
SQL> SELECT * from student_reg_entries;
no rows selected
The full information about this article is in the link I post before, I'm just showing this extract of the article because some people don't like to read links....
Cheers,
Francisco Munoz Alvarez
http://www.oraclenz.com
Maybe you are looking for
-
How do I access purchased music across all platforms?
Music previously purchased in iTunes is now in the 'music' app on my iPad mini. It's no longer on my iTunes playlist. How do I access this music on my MacBook air?
-
CR for VS 2005 x64 Redistributable issue
Post Author: [email protected] CA Forum: .NET Sorry if this question/issue has been asked and answered before, but this is my first post. I'm having issues installing the redistributable in an Intel Xeon dual-core environment. I tried the same steps
-
Class when transporting generating error
Hi Experts, I have created zclasses in SE24.While transporting them,one of them is giving error as Program ZCLASS==========CP:Syntax error in line 0011 Include Report ZCLASS========CO not found. I tried to give the program in SE38.But its saying not
-
Want to get rid of DBLINKS between locations
Hi We got one challenge to work out, Between location in OWB it creates CONNECTORS. These connectors are nothing but DBLink objects in the database. Basically client does not want this connector to be used in generated code . So we need to suppress t
-
My iPod got slightly wet but only slightly. Could this have done it?