TopLink, use of Oracle Temporary tables
A project using TopLink has the following questions. Could someone help answer them?
Does TopLink support the use of Oracle Temporary tables?
Is there any recommendation regarding the two possible ways of setting them up, see below:
ON COMMIT Setting Description DELETE ROWS This creates a temporary table that is transaction specific. A session becomes bound to the temporary table with a transactions first insert into the table. The binding goes away at the end of the transaction. The database truncates the table (delete all rows) after each commit.
PRESERVE ROWS This creates a temporary table that is session specific. A session gets bound to the temporary table with the first insert into the table in the session. This binding goes away at the end of the session or by issuing a TRUNCATE of the table in the session. The database truncates the table when you terminate the session.
We appreciate your assistance.
Haiwei
Haiwei,
TopLink has no explicit support for temporary tables but it should be possible. It is tough to answer your question since it really depends upon connection and transaction management for either case. What is your planned configuration TopLink with respect to external versus internal connection pooling as well as the JTA TX management.
I believe you are deploying your applications within WebSphere but would just like to confirm that you are using WAS data sources and transaction management.
Doug
Similar Messages
-
Hi ,
we have a application for transfering data approx 1 million records from one schema to another. the data is first inserted into a table temporarily and after all the data is transfered the data is manually deleted from this table.
we are planning to replace this table with Oracle Temporary table. Can you please let us know if this would increase the performance and why???
Thanks & Regards
SarojIn theory it should, but you won't know whether the difference is going to be noticeable until you try.
Oracle has to do much less work with global temporary tables. It knows no other sessions will be using the data so it does not need to bother with rollback segments or locks. It also does not bother with redo because there will not be a need to recover. -
Can oracle temporary tables be used with distributed transactions?
Hello,
Does anybody know if temporary tables are supported with distributed transactions?
We use a temporary table to store query results and see no problems when the JDBC driver (Type 2 or Type 4) is used with local transactions. The temporary tables are set for transaction-level data persistence (delete rows on commit).
When we switch to JDBC/XA driver we occasionally get ORA-14450 error (java.sql.SQLException: ORA-14450: attempt to access a transactional temp table already in use).
Many thanks...I have been able to use temporary tables on remote databases, so I don't think that it is forbidden. Of course, I'm not using JDBC so that might be a problem.
The other thing that occurs to me is that you are doing something other than DML with the table e.g. trying to drop it. If that is the case you should re-read the documentation and remind yourself of the purpose of temporary tables.
Cheers, APC -
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 -
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 -
Need help recreating this in Oracle (Temporary Table and a Cursor)
Hey all,
My client has asked me to see if it's possible to move his SQL Queries into Oracle, and then move EVERYTHING off of MSSQL into this new oracle environment. The problem is, I wrote the entire MSSQL system, and i know nothing about Oracle.
Basically, I need some examples. I have been stumbling around Oracle for about a year now, so i'm 'somewhat' familiar with it.
Basically, i'm going to create a script/stored procedure that will first:
Create and define a temporary table that is used when the script/proc is called.
Then, thru cursors, i'm going to add a bunch of lines to it.
Finally, i'm going to Run a select statement against the temporary table we created.
Now, I can't create a table on the server, as the production environment will not allow it, so i need to be able to create this virtually inside the script, and then it automatically self destructs at the end of the script.
If anyone knows if this is possible, please post me a few links to examples, or just lay down the code to get the temprary table made.
We're using TOAD as the interface.
Thanks,
DanThank you for the warm welcome.
The SQL looks something like this:
(Before you get lost in the code, this is an abreviation of the code, but every function is represented. This will also work in TOAD Script? I'm most worried about the use of how a Table is declared in Oracle, as i've seen many different versions of how to do this. Thanks)
~Dan
Declare @AREA nvarchar(50)
Declare @tmpTable Table (
[AC_PROPERTY_ID] [INT] NULL,
[PROPNUM] [nvarchar](50) NULL,
[SORT_ORDER] [INT] NULL,
[IS_TOTAL] [BIT] NULL,
[FIELD] [nvarchar](200) NULL,
[AREA] [nvarchar](200) NULL,
[ENG] [nvarchar](200) NULL,
[RSV_CAT] [nvarchar](200) NULL,
[WELL_NAME] [nvarchar](200) NULL,
[SHORTS_PROGRAM] [nvarchar](15) NULL,
[SHORT_MO] [nvarchar](6) NULL,
[SHORTS_YR] [nvarchar](6) NULL,
[SHORTS_DESC] [nvarchar](100) NULL)
Insert Into @tmpTable ([AC_PROPERTY_ID],[PROPNUM],[FIELD],[AREA],[ENG],[RSV_CAT],[WELL_NAME],[SHORTS_PROGRAM],[SHORT_MO],[SHORTS_YR],[SHORTS_DESC])
Select AC_PROPERTY_ID],[PROPNUM],[FIELD],[AREA],[ENG],[RSV_CAT],[WELL_NAME],[SHORTS_PROGRAM],[SHORT_MO],[SHORTS_YR],[SHORTS_DESC] from dbo.someoldtablenameimadeup where propnum>1000
DECLARE idcursor cursor
FOR
Select Distinct AREA
from @tmpTable
Open idcursor
Fetch Next from idcursor into @AREA
While (@@FETCH_STATUS <> -1)
BEGIN
IF (@@FETCH_STATUS <> -2)
<Do stuff for each record in the cursor>
FETCH NEXT FROM idcursor INTO @AREA
END
CLOSE idcursor
DEALLOCATE idcursor -
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 -
View definition using Temporary table
I am trying to create a view using a global temporary table Odyssey.HMSg_ReportGeneral :
create or replace view Odyssey.av_hms_TmpTbl_rpt_ClsGndr4dtsSub1
as select nvl(p.Gender,'Either') gender, bldg.Building Bldg, bldg.Site_Name Parent1, bldg.Room_Name name,
bldg.Building_Name Parent2, bldg.facility_sk_fk facility_sk, nvl(pc.Class,'Unspecified') Class, p.patron_sk,
count(t1.Patron_SK_FK) NumOccupants, nvl(pc.listing_order,0) ListOrd
from Odyssey.HMSg_ReportGeneral g,Odyssey.av_hms_rpt_ThisAssignmentLevel fa3
join Odyssey.av_hms_rpt_FacilityStructure bldg on(bldg.facility_sk_fk = fa3.facility_sk_FK and
(bldg.effectivedate is null or(bldg.effectivedate <= g.Date2 and(bldg.enddate is null or
bldg.enddate >= g.Date2)))) left outer join Odyssey.av_hms_rpt_NumOccupantsNoCount t1
on(t1.Facility_SK = bldg.facility_sk_fk and
(t1.elementstart is null or(t1.elementstart <= g.date2 and(t1.elementend is null or
t1.elementend >= g.date2)))) left outer join Odyssey.csdp_patron p
on(p.patron_SK = t1.patron_SK_FK) left outer join Odyssey.av_hms_rpt_PatronClass pc
on(pc.Patron_SK_FK = t1.Patron_SK_FK and(pc.effectivedate is null or (pc.effectivedate <=
g.date2 and(pc.enddate is null or pc.enddate >= g.date2))))
where fa3.effectivedate is null or(fa3.effectivedate <= g.Date1 and(fa3.enddate is null or fa3.enddate >= g.Date1))
group by bldg.Site_Name, bldg.Building_Name,bldg.Building, pc.Class, pc.listing_order, p.patron_sk, p.Gender,
bldg.facility_sk_fk, bldg.Room_Name
I get an error :
ORA-00904: "G"."DATE2": invalid identifier
If I removed all references to the global temporary table,
the view compiles fine - references to any of the columns in the temporary table give the ORA-00904.
Any suggestions ?
(FYI we are converting a database from Sybase to Oracle and have almost 20 views like this)
Thanks for the helpHi
After some test following I got following code to compile.
create or replace view Odyssey.hms_TmpTbl_rpt_ClsGndr4dtsSub1 as
select nvl(p.Gender,'Either') gender,
bldg.Building Bldg,
bldg.Site_Name Parent1,
bldg.Room_Name name,
bldg.Building_Name Parent2,
bldg.facility_sk_fk facility_sk,
nvl(pc.Class,'Unspecified') Class,
p.patron_sk,
count(t1.Patron_SK_FK) NumOccupants,
nvl(pc.listing_order,0) ListOrd
from
Odyssey.HMSg_ReportGeneral g
join
Odyssey.av_hms_rpt_ThisAssignmentLevel fa3 on
fa3.effectivedate is null
or (
fa3.effectivedate <= g.Date1
and ( fa3.enddate is null
or fa3.enddate >= g.Date1
join
Odyssey.av_hms_rpt_FacilityStructure bldg on
( bldg.facility_sk_fk = fa3.facility_sk_FK
and ( bldg.effectivedate is null
or ( bldg.effectivedate <= g.Date2
and ( bldg.enddate is null
or bldg.enddate >= g.Date2
left outer join
Odyssey.av_hms_rpt_NumOccupantsNoCount t1 on
( t1.Facility_SK = bldg.facility_sk_fk
and ( t1.elementstart is null
or ( t1.elementstart <= g.date2
and ( t1.elementend is null
or t1.elementend >= g.date2
left outer join
Odyssey.csdp_patron p on
( p.patron_SK = t1.patron_SK_FK
left outer join
Odyssey.av_hms_rpt_PatronClass pc on
( pc.Patron_SK_FK = t1.Patron_SK_FK
and ( pc.effectivedate is null
or ( pc.effectivedate <= g.date2
and ( pc.enddate is null
or pc.enddate >= g.date2
group by
bldg.Site_Name,
bldg.Building_Name,
bldg.Building,
pc.Class,
pc.listing_order,
p.patron_sk,
p.Gender,
bldg.facility_sk_fk,
bldg.Room_NameI think you can't mix old and new type of writing
you have to do the join
between Odyssey.HMSg_ReportGeneral
and Odyssey.av_hms_rpt_ThisAssignmentLevel
to have Odyssey.HMSg_ReportGeneral in the join statement later on. -
Performance issue with Oracle Global Temporary table
Hi
Oracle version : 10.2.0.3.0 - Production
We have an application in Java / Oracle. Users request comes in XML and oracle parser parses it and inserts it into Global temporary tables and then Business Stored procedure picks data from these GTT's and do the required processing.
in the end data required response data is again inserted into response GTT's from which Response XML is generated.
Question : Is the use of Global temporary tables in Oracle degrades performance as we have large number of GTT's in our application approx. 5-600 such tables.
Regards,
Vikas KumarHi All,
Here is architecture of my application:
Java application creates XML from the screen values and then inserts that XML
into a framework(separate DB schema) table . then Java calls a Stored Procedure from same framework DB and in SP we have following steps.
1. It fatches XML from the XML type table and inserts XML into screen specific XML TYPE table in the framework DB Schema. This table has a trigger which parses XML and then inserts XML values into GTT which are created in separate product schemas.
2. it calls Product SP and then in product SP we have business logic. Product SP
does the execution and then inserts response into Response GTT.
3. Response XML is created by using XML generation function and response GTT.
I hope u will understand my architeture this time and now let me know if GTT are good in this scenario or not. also please not that i need data in GTT only during execution and not after that. i dont want to do specific delete which i have to do if i am using normal tables.
Regards,
Vikas Kumar -
Rapid and Huge growth of of used space of temporary tablespace
Hi,
Have a query (select) that run quick (no more than 10 seconds).
As soon I insert the data into a temporary table or even on physical table, the temporary table used space starts to growth very fast. The used space is totally used and the query crash since e reach the limit (65GB), or even more if I add more table files to temporary tablespace!
The problem also happen only if the period (dates) is one year (2013). If the period is the first trimestre of 2013 (same amount of data), the problem does not happen!!
I also confirm that on another instance ( a test one), even with less resources this ORACLE behavior do not happen. I confirm differente execution plan queries, between the two instances .
What I really do not understant is the behavior of the ORACLE with the huge and rapid growth!!!
Any one experiment such a similiar situation?
Thanks in advance,Rui
Plan
INSERT STATEMENT ALL_ROWSCost: 15.776 Bytes: 269 Cardinality: 1
28 LOAD TABLE CONVENTIONAL MIDIALOG_OLAP.MED_INVCOMP_FACTTMP_BEFGROUPBY
27 FILTER
26 NESTED LOOPS
24 NESTED LOOPS Cost: 15.776 Bytes: 269 Cardinality: 1
22 NESTED LOOPS Cost: 15.775 Bytes: 255 Cardinality: 1
19 NESTED LOOPS Cost: 15.774 Bytes: 205 Cardinality: 1
17 NESTED LOOPS Cost: 15.773 Bytes: 197 Cardinality: 1
14 NESTED LOOPS Cost: 15.770 Bytes: 180 Cardinality: 1
11 NESTED LOOPS Cost: 15.767 Bytes: 108 Cardinality: 1
9 HASH JOIN Cost: 15.757 Bytes: 8.346.500 Cardinality: 83.465
7 HASH JOIN Cost: 13.407 Bytes: 6.345.012 Cardinality: 83.487
5 HASH JOIN Cost: 11.163 Bytes: 5.010.550 Cardinality: 100.211
3 HASH JOIN Cost: 5.642 Bytes: 801.288 Cardinality: 22.258
1 INDEX RANGE SCAN INDEX MIDIALOG.IX_INSCOMP_DTCEIDICIDLCPECIDOP Cost: 120 Bytes: 489.676 Cardinality: 22.258
2 INDEX FAST FULL SCAN INDEX (UNIQUE) MIDIALOG.IX_LINHACOMPRADA_IDLCIDOPSEQ Cost: 5.463 Bytes: 123.975.530 Cardinality: 8.855.395
4 INDEX FAST FULL SCAN INDEX (UNIQUE) MIDIALOG.IX_LINHACOMPRADA_IDLCIDOPSEQ Cost: 5.463 Bytes: 123.975.530 Cardinality: 8.855.395
6 TABLE ACCESS FULL TABLE MIDIALOG.ITEM_AV Cost: 1.569 Bytes: 6.963.736 Cardinality: 267.836
8 TABLE ACCESS FULL TABLE MIDIALOG.ITEM_AV Cost: 1.572 Bytes: 7.713.672 Cardinality: 321.403
10 INDEX UNIQUE SCAN INDEX (UNIQUE) MIDIALOG.IX_BOFINALBO_IDBOIDFINALBO Cost: 0 Bytes: 8 Cardinality: 1
13 TABLE ACCESS BY INDEX ROWID TABLE MIDIALOG.INSERCAO_COMPRADA Cost: 3 Bytes: 72 Cardinality: 1
12 INDEX RANGE SCAN INDEX (UNIQUE) MIDIALOG.IX_INSCOMPRADA_IDLCDATAPECAINS Cost: 2 Cardinality: 1
16 TABLE ACCESS BY INDEX ROWID TABLE MIDIALOG.INSERCAO_ITEMFACTURA Cost: 3 Bytes: 17 Cardinality: 1
15 INDEX RANGE SCAN INDEX MIDIALOG.IX_INSITFACT_INSCOMPRADA Cost: 2 Cardinality: 1
18 INDEX RANGE SCAN INDEX (UNIQUE) MIDIALOG.UQ_ITEMFACTURA_IDITF_IDFACT Cost: 1 Bytes: 8 Cardinality: 1
21 TABLE ACCESS BY INDEX ROWID TABLE MIDIALOG.FATURA Cost: 1 Bytes: 50 Cardinality: 1
20 INDEX UNIQUE SCAN INDEX (UNIQUE) MIDIALOG.PK_FATURA Cost: 0 Cardinality: 1
23 INDEX UNIQUE SCAN INDEX (UNIQUE) MIDIALOG.PK_TIPO_ESTADO Cost: 0 Cardinality: 1
25 TABLE ACCESS BY INDEX ROWID TABLE MIDIALOG.TIPO_ESTADO Cost: 1 Bytes: 14 Cardinality: 1
Edited by: rr**** on 19/Fev/2013 15:25I run the select with sucess, no more that 1 minute from on year of data. Few temporary used space used.
As soon I plug the insert (global temporary table, also experiment with physical table) the used space of temporary table space start to grow crazy!!
insert into midialog_olap.med_invcomp_facttmp_befgroupby
select fac.numefatura,
fac.codpessoa,
fac.dtemiss,
tef.nome as estado_factura,
opsorig.demid,
opsorig.anoplano,
opsorig.numplano,
opsorig.numplanilha,
ops.nome as ordem_publicidade,
ops.external_number as numero_externo,
ops.estado,
lic.seq,
inc.data,
inc.peca,
fac.id_versao_plano,
fac.ano_proforma || '.' || fac.numrf as num_proforma,
iif.tipo_facturacao,
opsorig.codveiculo as id_veiculo,
opsorig.codfm as id_fornecedor_media,
icorig.chkestado as id_estado_checking,
0 as percentagem_comissao_agencia,
0 as valor_pbv,
0 as valor_stxtv,
0 as valor_ptv,
0 as valor_odbv,
0 as valor_pbbv,
0 as valor_dnv,
0 as valor_pbnv,
0 as valor_stxv,
0 as valor_pbtv,
0 as valor_dav,
0 as valor_plv,
0 as valor_odlv,
0 as valor_pllv,
0 as valor_ca,
0 as valor_trv,
0 as valor_txv,
0 as valor_base_facturacao,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_pb_compra * fac.percentagem_facturada / 100))
as valor_pbc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_stxt_compra * fac.percentagem_facturada / 100))
as valor_stxtc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_pt_compra * fac.percentagem_facturada / 100))
as valor_ptc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_odb_compra * fac.percentagem_facturada / 100))
as valor_odbc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_pbb_compra * fac.percentagem_facturada / 100))
as valor_pbbc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_dn_compra * fac.percentagem_facturada / 100))
as valor_dnc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_pbn_compra * fac.percentagem_facturada / 100))
as valor_pbnc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_stx_compra * fac.percentagem_facturada / 100))
as valor_stxc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_pbt_compra * fac.percentagem_facturada / 100))
as valor_pbtc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_da_compra * fac.percentagem_facturada / 100))
as valor_dac,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_pl_compra * fac.percentagem_facturada / 100))
as valor_plc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_odl_compra * fac.percentagem_facturada / 100))
as valor_odlc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_pll_compra * fac.percentagem_facturada / 100))
as valor_pllc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_transcricoes * fac.percentagem_facturada / 100))
as valor_trc,
decode(ops.estado, :WKFOPR_BOOKINGORDER_CANCELED, 0,
decode(iif.tipo_facturacao, :BILLING_TYPE_ONLYCOMISSION, 0,
inc.total_tx_compra * fac.percentagem_facturada / 100))
as valor_txc,
--nvl((select cfm.total_comprado
-- from fin_custos_facturados_media cfm
-- where cfm.id_factura = fac.id_factura and
- -- cfm.id_op = ops.id_op
-- ), 0) / opsorig.number_of_bought_insertions as custos_associados,
0 as custos_associados,
fac.iss as percentagem_iva,
fac.percentagem_facturada,
fac.currency_exchange as taxa_cambio,
iif.associated_code as insertions_associated_code
from fatura fac, item_fatura itf, insercao_itemfactura iif,
insercao_comprada icorig, linha_comprada lcorig, item_av opsorig,
med_bookingorder_finalbo opfin,
insercao_comprada inc,
linha_comprada lic, item_av ops,
--veiculo vei,
tipo_estado tef
where fac.id_factura = itf.id_factura and
itf.id_itemfactura = iif.id_itemfactura and
iif.id_ic = icorig.id_ic and
icorig.id_lc = lcorig.id_lc and
lcorig.id_op = opsorig.id_op and
opsorig.id_op = opfin.id_booking_order and
opsorig.number_of_bought_insertions > 0 and
opfin.id_final_booking_order = ops.id_op and
-- ops.id_op = (
-- select max(ops.id_op)
-- from item_av ops
-- start with ops.id_op = opsorig.id_op
-- connect by prior ops.id_opsubstituicao = ops.id_op) and
ops.id_op = lic.id_op and
lic.seq = lcorig.seq and
lic.id_op = inc.id_op and
lic.id_lc = inc.id_lc and
inc.data = icorig.data and
inc.peca = icorig.peca and
--opsorig.codveiculo = vei.codveiculo and
fac.estado = tef.estado and
fac.estado != 305 and
ops.estado != 223 and
iif.tipo_facturacao != 'SO_CA' and
icorig.data between :dtBeginDate and :dtEndDate and
(fac.codagenciafat = :iIdAgency or :iIdAgency is null); -
Database temporary tables alternative?
Hello!
I would like to know if ADF supports the use of temporary tables in Oracle database? I would probably have to use dedicated connections for every application user, but I can't find anything on this matter. Is it even possible? If not, what are the alternatives? Can someone point me to the right direction on what and where to start searching?
Thank you for any useful info!I've used temporary tables in ADF applications, and it works, but it is very dangerous - you have to fully understand how ADF (and JEE in general) maintains state in what is essentially a stateless environment. The problem is if you load a temporary table on one database round-trip, you cannot depend that it will still contain the same data (or any data) on another round-trip. There is no guarantee that the session will use the same database session, or that some other user hasn't used the same database session in between. So about the only good use of a temporary table is for a temporary work area during the execution of a stored procedure where it will be re-loaded on every call.
In fact, I'm working on a new version of my ADF application that used temporary tables to get rid of them. -
Using the Workbench to convert a Sybase 11 application to 8i, I've seen all the Oracle temporary tables created as "... on commit preserve rows". But we want the temps to only have transaction duration rather than session. Is there any way to tweak the tool to create temporary tables as "... on commit delete rows"?
I had used the Migration Workbench against
MS SQL Server 7.0. to migrate to Oracle 8.1.6.
All the temp tables created in T-SQL stored
procedures where converted in permanent tables.
So not even the Oracle 8i temp tables session
based were created as clamined by the author
of this thread.
My question is there a option to create temp tables (session based) for all the temp tables created via T-SQL. -
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 -
Interactive report based on a temporary table?
hi -- I'm trying to get around some performance issues using database links, and the use of global temporary tables was suggested.
However, the performance issue is in defining the query for an interactive report... and the allowable source for these seems to be more particular
than for other queries / reports.
I currently use asa collection the source of data for the IR -- works, but is SLOW for DB links.
I don't know how much benefit to expect from the use of a global temporary table... but it seems I can't
create an IR based on a temporary table... as when the query is parsed the table does not exist.
Am I missing something? Has anyone done this?
Thanks,
CarolIf you build the global temporary table and leave it in place, then it might work. Deleting and creating tables on the fly is NOT really suggested in Oracle. When you need to, you could in the page header execute a procedure to select/insert into the global temp table, since they normally clear out when your session is complete..
Thank you,
Tony Miller
Webster, TX -
Need Advise on Global Temporary tables or Materialized views or Views
Need advise on a plsql procedure working on.
I had 6 tables having 200,000 rows in total intially,but will get added a maximum 20,000 rows daily by a batch process.
I am writing a plsql code that takes an input ,for example customer_id, and is required to get all the data for that customer_id and
had to do some complex calculation that includes stepwise validations before giving the output.Now while doing the logic it has the get the data for that customer_id from all the tables.
There may be 100 records for that particular customer_id.
I need advise on the below options.
1.Use of global temporary tables get those 100 records and do the calculation part on that Global Temporary table.
2.Use of Views or Materialized views.
3.Using the Record Structures(like table types for those records) and then do the logic on them
As Performance is the key point here i would like pull all the data at once into memory and then do the calculations instead of hitting the database many times, this is my main idea(correct me if am wrong).Also please advise if there are any other options
I am using ORACLE 10G.
Thanks
RedeThe approach that many advocate for here (including myself) is to do as much in SQL as possible. So, copying to GTTs or using record structures is probably not the solution you should be after.
If you can provide the following details we may be able to steer you down the right path
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
Ideally try and re-create the problem, simplifying it as much as possible, without losing context. Use #1-#5 above as a base for posting your simplified problem here. Then we may be able to give you a solution specific to your problem.
Maybe you are looking for
-
Is it possible to install Windows Xp on a USB
I have a Macbook pro 13inch, I would like to install Windows XP in a USB drive I would like to know whether it is possible or not, I don't want to dual boot If yes can any one please tell me how to do it
-
hi my mum has a new ipad which was set up at my uncles house down south . my niece has blocked the ipad putting the wrong password into it and i need to reset the ipad back to the original settings but dont know how to set it up having 2 seperate acc
-
Im recording TV-shows and compressing them in h.264 640x480 and everything works fine. Artwork to. All mp4 But now, Ive got this one show causing som problems. First of all, when I set it to TV-show (as with the others) it appears in tv-shows all rig
-
How do I get it back to normal?
My ipod is in extreme zoom in and I can't get it back to normal
-
Store the Printing Metadata for each picture
2) Can Lightroom store print metadata (font size/color, scaling factor) for each picture and for each virtual copy the way it already stores Vibrance, virtual copies, tone curves, etc. information? Suppose Photo1 and Photo2 have widely different titl