Excel ADODB Sql Query Execution taking hours when manipulate excel tables
Hello All
I have 28000 records with 8 column in an sheet. When I convert the sheet into ADODB database and copy to new
excel using below code it is executing in less than a min
Set Tables_conn_obj = New ADODB.Connection
Tables_conn_str = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Table_Filename & ";Extended Properties=""Excel 12.0;ReadOnly=False;HDR = Yes;IMEX=1"""
Tables_conn_obj.Open Tables_conn_str
First_Temp_sqlqry = "Select * INTO [Excel 12.0;DATABASE=C:\Prod Validation\Database\Second Acat Table.xlsb].[Sheet1] Table [first - Table$];" Tables_conn_obj.Execute First_Temp_sqlqry
But when I change the query to manipulate one column in current table based on another table in the same excel
and try to copy the results in another excel, it is taking more than one hour.. why it is taking this much time when both the query results returns the same number of rows and column. I almost spend one week and still not able to resolve this issue.
Even I tried copyfromrecordset, getrows(), getstring(), Looping each recordset fields options all of them taking
same amount of time. Why there is huge difference in execution time.
Important note: Without into statement even below query is executing in few seconds.
select ( ''''''manipulating first column based on other table data''''''''''''''
iif(
[Second - Table$].[Policy Agent] = (select max([ACAT$].[new_Agent_number]) from [ACAT$] where [ACAT$].[new_Agent_number] = [Second - Table$].[Policy Agent] and [ACAT$].[ACAT_EffectiveDate] = ( select MAX([ACAT$].[ACAT_EffectiveDate] ) from [ACAT$] where [ACAT$].[new_Agent_number] = [Second - Table$].[Policy Agent]and [ACAT$].[ACAT_EffectiveDate] > '2014-10-01') ) , (select max([ACAT$].[Old_Agent_number]) from [ACAT$] where [ACAT$].[new_Agent_number] = [Second - Table$].[Policy Agent] and [ACAT$].[ACAT_EffectiveDate] = ( select MAX([ACAT$].[ACAT_EffectiveDate] ) from [ACAT$] where [ACAT$].[new_Agent_number] = [Second - Table$].[Policy Agent]and [ACAT$].[ACAT_EffectiveDate] > '2014-10-01')) ,
iif( [Second - Table$].[Policy Agent] = (select max([ACAT$].[Old_Agent_number]) from [ACAT$] where [ACAT$].[Old_Agent_number] = [Second - Table$].[Policy Agent] and [ACAT$].[ACAT_EffectiveDate] = ( select MAX([ACAT$].[ACAT_EffectiveDate] ) from [ACAT$]where [ACA T$].[Old_Agent_number] = [Second - Table$].[Policy Agent]and [ACAT$].[ACAT_EffectiveDate] <= '2014-10-01') ), (select max([ACAT$].[new_Agent_number]) from [ACAT$] where [ACAT$].[Old_Agent_number] = [Second - Table$].[Policy Agent] and [ACAT$].[ACAT_EffectiveDate] = ( select MAX([ACAT$].[ACAT_EffectiveDate] ) from [ACAT$] where [ACAT$].[Old_Agent_number] = [Second - Table$].[Policy Agent]and [ACAT$].[ACAT_EffectiveDate] <= '2014-10-01')) ,
[Second - Table$].[Policy Agent] ))) as [Policy Agent],
''''''summing up all other columns''''''''''''''
(iif(isnull(sum([Second - Table$].[Auto BW-Line Of Business Detail])),0,sum([Second - Table$].[Auto BW-Line Of Business Detail]))) as [Auto BW-Line Of Business Detail],(iif(isnull(sum([Second - Table$].[Auto Farmers])),0,sum([Second - Table$].[Auto Farmers]))) as [Auto Farmers],(iif(isnull(sum([Second - Table$].[MCA])),0,sum([Second - Table$].[MCA]))) as [MCA],(iif(isnull(sum([Second - Table$].[CEA])),0,sum([Second - Table$].[CEA]))) as [CEA],(iif(isnull(sum([Second - Table$].[Commercial P&C])),0,sum([Second - Table$].[Commercial P&C]))) as [Commercial P&C],(iif(isnull(sum([Second - Table$].[Comm WC])),0,sum([Second - Table$].[Comm WC]))) as [Comm WC],(iif(isnull(sum([Second - Table$].[Fire Farmers])),0,sum([Second - Table$].[Fire Farmers]))) as [Fire Farmers],(iif(isnull(sum([Second - Table$].[Flood])),0,sum([Second - Table$].[Flood]))) as [Flood],(iif(isnull(sum([Second - Table$].[Kraft Lake])),0,sum([Second - Table$].[Kraft Lake]))) as [Kraft Lake],(iif(isnull(sum([Second - Table$].[Life])),0,sum([Second - Table$].[Life]))) as [Life],(iif(isnull(sum([Second - Table$].[Foremost])),0,sum([Second - Table$].[Foremost]))) as [Foremost],(iif(isnull(sum([Second - Table$].[Umbrella])),0,sum([Second - Table$].[Umbrella]))) as [Umbrella],(iif(isnull(sum([Second - Table$].[MCNA])),0,sum([Second - Table$].[MCNA]))) as [MCNA]
INTO [Excel 12.0;DATABASE=C:\Prod Validation\Database\Second Acat Table.xlsb].[Sheet1]
from [Second - Table$] group by [Second - Table$].[Policy Agent] ;
Hi Fei,
Thank you so much for the reply post. I just executed the same above SQL without INTO Statement and assigned the SQL result to ADODB recordset as below. If the time difference is due to the SQL query then below statements also should execute for hours
right, but it gets executed in seconds. But to copy the recordset to excel again it is taking hours. I tried copyfromrecordset,
getrows(), getstring(), Looping each recordset fields options and all of them taking same amount of time. Please let me know there is delay in time for this much small data
Even I tried to typecast all columns to double, string in SQL and still the execution time is not reduced.
First_Temp_Recordset.Open sql_qry, Tables_conn_obj, adOpenStatic, adLockOptimistic ''' OR SET First_Temp_Recordset = Tables_conn_obj.Execute sql_qry
Similar Messages
-
Excel ADODB Sql Query Execution taking hours when manipulate excel tables why?
I have 28000 records with 8 column in an sheet. When I convert the sheet into ADODB database and copy to new excel using below code it is executing in less than a min
Set Tables_conn_obj = New ADODB.Connection Tables_conn_str = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Table_Filename & ";Extended Properties=""Excel 12.0;ReadOnly=False;HDR = Yes;IMEX=1""" Tables_conn_obj.Open
Tables_conn_str First_Temp_sqlqry = "Select * INTO [Excel 12.0;DATABASE=C:\Prod Validation\Database\Second Acat Table.xlsb].[Sheet1] Table [first - Table$];" Tables_conn_obj.Execute First_Temp_sqlqry
But when I change the query to manipulate one column in current table based on another table in the same excel and try to copy the results in another excel, it is taking more than one hour.. why it is taking this much time when both the query results returns
the same number of rows and column. I almost spend one week and still not able to resolve this issue.
Even I tried copyfromrecordset, getrows(), getstring(), Looping each recordset fields options all of them taking same amount of time. Appreciate any inputs...
select ( ''''''manipulating first column based on other table data''''''''''''''
iif( [Second - Table$].[Policy Agent] = (select max([ACAT$].[new_Agent_number]) from [ACAT$] where [ACAT$].[new_Agent_number] = [Second - Table$].[Policy Agent] and [ACAT$].[ACAT_EffectiveDate] = ( select MAX([ACAT$].[ACAT_EffectiveDate] ) from [ACAT$] where
[ACAT$].[new_Agent_number] = [Second - Table$].[Policy Agent]and [ACAT$].[ACAT_EffectiveDate] > '2014-10-01') ) , (select max([ACAT$].[Old_Agent_number]) from [ACAT$] where [ACAT$].[new_Agent_number] = [Second - Table$].[Policy Agent] and [ACAT$].[ACAT_EffectiveDate]
= ( select MAX([ACAT$].[ACAT_EffectiveDate] ) from [ACAT$] where [ACAT$].[new_Agent_number] = [Second - Table$].[Policy Agent]and [ACAT$].[ACAT_EffectiveDate] > '2014-10-01')) ,
iif( [Second - Table$].[Policy Agent] = (select max([ACAT$].[Old_Agent_number]) from [ACAT$] where [ACAT$].[Old_Agent_number] = [Second - Table$].[Policy Agent] and [ACAT$].[ACAT_EffectiveDate] = ( select MAX([ACAT$].[ACAT_EffectiveDate] ) from [ACAT$]where
[ACA T$].[Old_Agent_number] = [Second - Table$].[Policy Agent]and [ACAT$].[ACAT_EffectiveDate] <= '2014-10-01') ), (select max([ACAT$].[new_Agent_number]) from [ACAT$] where [ACAT$].[Old_Agent_number] = [Second - Table$].[Policy Agent] and [ACAT$].[ACAT_EffectiveDate]
= ( select MAX([ACAT$].[ACAT_EffectiveDate] ) from [ACAT$] where [ACAT$].[Old_Agent_number] = [Second - Table$].[Policy Agent]and [ACAT$].[ACAT_EffectiveDate] <= '2014-10-01')) ,
[Second - Table$].[Policy Agent] ))) as [Policy Agent],
''''''summing up all other columns''''''''''''''
(iif(isnull(sum([Second - Table$].[Auto BW-Line Of Business Detail])),0,sum([Second - Table$].[Auto BW-Line Of Business Detail]))) as [Auto BW-Line Of Business Detail],(iif(isnull(sum([Second - Table$].[Auto Farmers])),0,sum([Second - Table$].[Auto Farmers])))
as [Auto Farmers],(iif(isnull(sum([Second - Table$].[MCA])),0,sum([Second - Table$].[MCA]))) as [MCA],(iif(isnull(sum([Second - Table$].[CEA])),0,sum([Second - Table$].[CEA]))) as [CEA],(iif(isnull(sum([Second - Table$].[Commercial P&C])),0,sum([Second
- Table$].[Commercial P&C]))) as [Commercial P&C],(iif(isnull(sum([Second - Table$].[Comm WC])),0,sum([Second - Table$].[Comm WC]))) as [Comm WC],(iif(isnull(sum([Second - Table$].[Fire Farmers])),0,sum([Second - Table$].[Fire Farmers]))) as [Fire
Farmers],(iif(isnull(sum([Second - Table$].[Flood])),0,sum([Second - Table$].[Flood]))) as [Flood],(iif(isnull(sum([Second - Table$].[Kraft Lake])),0,sum([Second - Table$].[Kraft Lake]))) as [Kraft Lake],(iif(isnull(sum([Second - Table$].[Life])),0,sum([Second
- Table$].[Life]))) as [Life],(iif(isnull(sum([Second - Table$].[Foremost])),0,sum([Second - Table$].[Foremost]))) as [Foremost],(iif(isnull(sum([Second - Table$].[Umbrella])),0,sum([Second - Table$].[Umbrella]))) as [Umbrella],(iif(isnull(sum([Second - Table$].[MCNA])),0,sum([Second
- Table$].[MCNA]))) as [MCNA]
INTO [Excel 12.0;DATABASE=C:\Prod Validation\Database\Second Acat Table.xlsb].[Sheet1]
from [Second - Table$] group by [Second - Table$].[Policy Agent] ;Hi Fei,
Thank you so much for the reply post. I just executed the same above SQL without INTO Statement and assigned the SQL result to ADODB recordset as below. If the time difference is due to the SQL query then below statements also should execute for hours
right, but it gets executed in seconds. But to copy the recordset to excel again it is taking hours. I tried copyfromrecordset,
getrows(), getstring(), Looping each recordset fields options and all of them taking same amount of time. Please let me know there is delay in time for this much small data
Even I tried to typecast all columns to double, string in SQL and still the execution time is not reduced.
First_Temp_Recordset.Open sql_qry, Tables_conn_obj, adOpenStatic, adLockOptimistic ''' OR SET First_Temp_Recordset = Tables_conn_obj.Execute sql_qry -
My sql query is taking hours to run from toad
SELECT * from (select hr.NAME org_name, ractla.org_id, acct_site.attribute_category,
acct_site.attribute10 general_agent, arc.reversal_category,arr.reversal_gl_date,ard.reversed_source_id,
DECODE (acct_site.attribute_category,
'COMM', acct_site.attribute9,
'IPLAN', acct_site.attribute11,
NULL
) broker_number, -- changed by Michelle
SUBSTR (hca.account_number, 1, 12) customer_number,
ractla.attribute3 plan_type,
SUBSTR (hp.party_name, 1, 15) customer_name,
DECODE (ractla.attribute_category,
'Commercial Receivables', ractla.attribute1,
'Subscriber Receivables', ractla.attribute1,
NULL
) product, --x Product
rax.trx_number trx_number, rax.trx_date transaction_date,
DECODE
(SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE
( '01'
|| TO_CHAR
(DECODE (SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE
(SUBSTR (rax.attribute4,
1,
10
'rrrr/mm/dd'
NULL
'MON-RRRR'
'DD-MON-RRRR'
NULL
) coverage_month,
DECODE (SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE (SUBSTR (rax.attribute4, 1, 10), 'rrrr/mm/dd'),
NULL
) due_date,
DECODE (acct_site.attribute_category,
'COMM', SUBSTR (hca.account_number, 1, 6),
acct_site.attribute10
) employer_group,
DECODE (arc.reversal_category,
'NSF', TRUNC (arr.creation_date),
'REV', TRUNC (arr.creation_date),
DECODE (arr.reversal_gl_date,
NULL, TRUNC (arr.apply_date),
DECODE (ard.reversed_source_id,
NULL, TRUNC (arr.apply_date),
TRUNC (arr.creation_date)
) as application_date,
arr.apply_date,
arr.creation_date, --9/8/03
arc.receipt_number receipt_number, arc.receipt_date receipt_date,
arr.amount_applied applied_amount, rax.attribute1 company,
rax.attribute2 division, ractla.attribute2 coverage_plan, -- (Plan Code)
DECODE (acct_site.attribute_category,
'IPLAN', acct_site.attribute13,
'SH', acct_site.attribute8,
NULL
) coverage_type,
ps.amount_due_original trans_amount,
NVL (ps.amount_due_remaining, 0) trans_amount_remaining,
SUBSTR (hre.first_name || ' ' || hre.middle_name || ' '
|| hre.last_name,
1,
25
) salesrep_name,
SUBSTR (acct_site.attribute5, 1, 5) salesrep_extension,
hca.attribute4 SOURCE
FROM apps.ra_customer_trx_all rax, -- invoice info
apps.ar_payment_schedules_all ps,
apps.ra_cust_trx_types_all rat,
apps.hz_cust_accounts_all hca,
apps.hz_parties hp,
apps.ar_receivable_applications_all arr,
apps.ar_cash_receipts_all arc, --- receipt info
apps.hr_operating_units hr,
apps.hr_employees hre,
apps.hz_cust_acct_sites_all acct_site,
apps.hz_cust_site_uses_all acct_site_use, --added by tapas on 7/16
apps.ra_customer_trx_lines_all ractla,
apps.ar_distributions_all ard
WHERE
hca.cust_account_id = rax.bill_to_customer_id
AND ps.customer_trx_id = rax.customer_trx_id
AND rat.cust_trx_type_id = rax.cust_trx_type_id
AND rat.org_id = rax.org_id
AND arr.applied_customer_trx_id = rax.customer_trx_id
AND arr.status = 'APP'
AND arr.cash_receipt_id = arc.cash_receipt_id
AND hr.organization_id = rax.org_id
AND rax.customer_trx_id = ractla.customer_trx_id
AND ractla.line_number = 1
AND rax.bill_to_site_use_id = acct_site_use.site_use_id
AND hca.cust_account_id = acct_site.cust_account_id
AND acct_site.cust_acct_site_id = acct_site_use.cust_acct_site_id
AND hca.party_id = hp.party_id
AND acct_site.attribute4 = hre.employee_id(+)
AND hr.NAME = 'Commercial Group'
AND ard.source_table = 'RA'
AND ard.source_id = arr.receivable_application_id) app
where app.application_date between :start_date and :end_Date
and app.application_date <> app.apply_date
and app.applied_amount>0;
This is my query..due to some requirement i have written an inline view. The query is getting executed without inline view and even after including inline view but when i included the condition "app.applied_amount>0" its taking hours and i dont see it complete. Please advise. Urgently needed as a discoverer report needs to be built based on this.
Thanks.
Edited by: 958913 on Oct 8, 2012 3:52 PM
Edited by: 958913 on Oct 8, 2012 4:19 PM
Edited by: 958913 on Oct 8, 2012 4:33 PMHi,
the next action plan i have taken is as i need to write a condition that is based on application date(which is not a database column and is getting by a decode statement in the select) i have removed that decode statement from select and written in inline view and there by adding in where condition. Here is the query and still its taking time to run.
/* Formatted on 2012/10/09 13:51 (Formatter Plus v4.8.8) */
SELECT hr.NAME org_name, ractla.org_id, acct_site.attribute_category,
acct_site.attribute10 general_agent, arc.reversal_category,
arr.reversal_gl_date, ard.reversed_source_id,
DECODE (acct_site.attribute_category,
'COMM', acct_site.attribute9,
'IPLAN', acct_site.attribute11,
NULL
) broker_number, -- changed by Michelle
SUBSTR (hca.account_number, 1, 12) customer_number,
ractla.attribute3 plan_type,
SUBSTR (hp.party_name, 1, 15) customer_name,
DECODE (ractla.attribute_category,
'Commercial Receivables', ractla.attribute1,
'Subscriber Receivables', ractla.attribute1,
NULL
) product, --x Product
rax.trx_number trx_number, rax.trx_date transaction_date,
DECODE
(SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE ( '01'
|| TO_CHAR (DECODE (SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE
(SUBSTR (rax.attribute4,
1,
10
'rrrr/mm/dd'
NULL
'MON-RRRR'
'DD-MON-RRRR'
NULL
) coverage_month,
DECODE (SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE (SUBSTR (rax.attribute4, 1, 10), 'rrrr/mm/dd'),
NULL
) due_date,
DECODE (acct_site.attribute_category,
'COMM', SUBSTR (hca.account_number, 1, 6),
acct_site.attribute10
) employer_group,
app.application_date,
arr.apply_date, arr.creation_date, --9/8/03
arc.receipt_number receipt_number,
arc.receipt_date receipt_date, arr.amount_applied applied_amount,
rax.attribute1 company, rax.attribute2 division,
ractla.attribute2 coverage_plan, -- (Plan Code)
DECODE (acct_site.attribute_category,
'IPLAN', acct_site.attribute13,
'SH', acct_site.attribute8,
NULL
) coverage_type,
ps.amount_due_original trans_amount,
NVL (ps.amount_due_remaining, 0) trans_amount_remaining,
SUBSTR (hre.first_name || ' ' || hre.middle_name || ' '
|| hre.last_name,
1,
25
) salesrep_name,
SUBSTR (acct_site.attribute5, 1, 5) salesrep_extension,
hca.attribute4 SOURCE
FROM apps.ra_customer_trx_all rax, -- invoice info
apps.ar_payment_schedules_all ps,
apps.ra_cust_trx_types_all rat,
apps.hz_cust_accounts_all hca,
apps.hz_parties hp,
apps.ar_receivable_applications_all arr,
apps.ar_cash_receipts_all arc, --- receipt info
apps.hr_operating_units hr,
apps.hr_employees hre,
apps.hz_cust_acct_sites_all acct_site,
apps.hz_cust_site_uses_all acct_site_use, --added by tapas on 7/16
apps.ra_customer_trx_lines_all ractla,
apps.ar_distributions_all ard,
(select rax1.customer_trx_id,DECODE (arc1.reversal_category,
'NSF', TRUNC (arr1.creation_date),
'REV', TRUNC (arr1.creation_date),
DECODE (arr1.reversal_gl_date,
NULL, TRUNC (arr1.apply_date),
DECODE (ard1.reversed_source_id,
NULL, TRUNC (arr1.apply_date),
TRUNC (arr1.creation_date)
) as application_date
from apps.ar_receivable_applications_all arr1,
apps.ar_cash_receipts_all arc1,
apps.ra_customer_trx_all rax1,
apps.ar_distributions_all ard1
where arr1.applied_customer_trx_id = rax1.customer_trx_id
AND arr1.status = 'APP'
AND arr1.cash_receipt_id = arc1.cash_receipt_id
AND ard1.source_table = 'RA'
AND ard1.source_id = arr1.receivable_application_id
) app
WHERE hca.cust_account_id = rax.bill_to_customer_id
AND app.customer_trx_id = rax.customer_trx_id
AND arr.apply_date <> app.application_date
and app.application_date between :start_date and :end_date
--AND rax.trx_number IN ('52715888', '52689753')
AND ps.customer_trx_id = rax.customer_trx_id
AND rat.cust_trx_type_id = rax.cust_trx_type_id
AND rat.org_id = rax.org_id
AND arr.applied_customer_trx_id = rax.customer_trx_id
AND arr.status = 'APP'
AND arr.cash_receipt_id = arc.cash_receipt_id
AND hr.organization_id = rax.org_id
AND rax.customer_trx_id = ractla.customer_trx_id
AND ractla.line_number = 1
AND rax.bill_to_site_use_id = acct_site_use.site_use_id
AND hca.cust_account_id = acct_site.cust_account_id
AND acct_site.cust_acct_site_id = acct_site_use.cust_acct_site_id
AND hca.party_id = hp.party_id
AND acct_site.attribute4 = hre.employee_id(+)
AND hr.NAME = 'Commercial Group'
AND ard.source_table = 'RA'
AND ard.source_id = arr.receivable_application_id -
Query is taking hours to give output
Hi All,
The following query is taking hours to give o/p,is there any way to optimize it for a better performance.
I took the expalin plan for the sql.
SELECT SUM(L.EXTENDED_AMOUNT)
FROM mtl_categories cat,
mtl_item_categories mic ,
RA_CUSTOMER_TRX_ALL H ,
RA_CUST_TRX_TYPES_ALL T ,
RA_CUSTOMER_TRX_LINES_ALL L
WHERE cat.category_id = 4341
AND cat.category_id = mic.category_id
AND mic.organization_id = 4
AND mic.category_set_id = 4
AND mic.inventory_item_id = l.inventory_item_id
AND TO_CHAR(H.TRX_DATE,'MON-RR')= 'MAR-12'
AND l.CUSTOMER_TRX_ID = H.CUSTOMER_TRX_ID
AND T.TYPE = 'INV'
AND T.NAME NOT IN ('PB-INV-MEMO', 'PB-RMA-MEMO','PB-CM-MEMO','JM-INV-MEMO','JM-RMA-MEMO','JM-CM-MEMO','JM-CO','PB-CO')
AND H.CUST_TRX_TYPE_ID = T.CUST_TRX_TYPE_ID
AND H.BILL_TO_CUSTOMER_ID =3284explain plan for the sql
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 1 | 89 | 417 |
| 1 | SORT AGGREGATE | | 1 | 89 | |
| 2 | TABLE ACCESS BY INDEX ROWID | RA_CUSTOMER_TRX_LINES_ALL | 1 | 15 | 3 |
| 3 | NESTED LOOPS | | 1 | 89 | 417 |
| 4 | NESTED LOOPS | | 42 | 3108 | 291 |
| 5 | MERGE JOIN CARTESIAN | | 56 | 2856 | 11 |
| 6 | NESTED LOOPS | | 1 | 28 | 8 |
| 7 | NESTED LOOPS | | 1 | 13 | 1 |
|* 8 | INDEX UNIQUE SCAN | MTL_CATEGORIES_B_U1 | 1 | 5 | 1 |
|* 9 | INDEX UNIQUE SCAN | MTL_CATEGORIES_TL_U1 | 1 | 8 | |
| 10 | TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES | 1 | 15 | 7 |
|* 11 | INDEX RANGE SCAN | MTL_ITEM_CATEGORIES_N1 | 1 | | 2 |
| 12 | BUFFER SORT | | 57 | 1311 | 4 |
|* 13 | TABLE ACCESS FULL | RA_CUST_TRX_TYPES_ALL | 57 | 1311 | 3 |
|* 14 | TABLE ACCESS BY INDEX ROWID | RA_CUSTOMER_TRX_ALL | 1 | 23 | 5 |
|* 15 | INDEX RANGE SCAN | RA_CUSTOMER_TRX_N11 | 26 | | 2 |
|* 16 | INDEX RANGE SCAN | JM_RA_CUSTOMER_TRX_LINES_N1 | 1 | | 2 |
8 - access("B"."CATEGORY_ID"=4341)
9 - access("T"."CATEGORY_ID"=4341 AND "T"."LANGUAGE"=:B1)
filter("B"."CATEGORY_ID"="T"."CATEGORY_ID")
11 - access("MIC"."ORGANIZATION_ID"=4 AND "MIC"."CATEGORY_SET_ID"=4 AND
"MIC"."CATEGORY_ID"=4341)
filter("B"."CATEGORY_ID"="MIC"."CATEGORY_ID")
13 - filter("SYS_ALIAS_0000"."TYPE"='INV' AND "SYS_ALIAS_0000"."NAME"<>'PB-INV-MEMO' AND
"SYS_ALIAS_0000"."NAME"<>'PB-RMA-MEMO' AND "SYS_ALIAS_0000"."NAME"<>'PB-CM-MEMO' AND
"SYS_ALIAS_0000"."NAME"<>'JM-INV-MEMO' AND "SYS_ALIAS_0000"."NAME"<>'JM-RMA-MEMO' AND
"SYS_ALIAS_0000"."NAME"<>'JM-CM-MEMO' AND "SYS_ALIAS_0000"."NAME"<>'JM-CO' AND
"SYS_ALIAS_0000"."NAME"<>'PB-CO')
14 - filter(TO_CHAR("H"."TRX_DATE",'MON-RR')='MAR-12')
15 - access("H"."BILL_TO_CUSTOMER_ID"=3284 AND
"H"."CUST_TRX_TYPE_ID"="SYS_ALIAS_0000"."CUST_TRX_TYPE_ID")
16 - access("L"."CUSTOMER_TRX_ID"="H"."CUSTOMER_TRX_ID" AND
"MIC"."INVENTORY_ITEM_ID"="L"."INVENTORY_ITEM_ID")
Note: cpu costing is off -
Getting error "SQL error in the database when accessing a table."
Hi All,
We are getting Dump Error SQL error in the database when accessing a table for the batch job EISSD/REQUISITION 14 / which includes program AQ20FD==========A2============. Please reply. The Dump error details are as follows
Short text
SQL error in the database when accessing a table.
How to correct the error
Database error text........: "ORA-01555: snapshot too old: rollback segment
number 21 with name "_SYSSMU21$" too small"
Internal call code.........: "[RSQL/FTCH/VBRK ]"
Please check the entries in the system log (Transaction SM21).
Thanks
Padmakar Kudtarkar
Edited by: Rob Burbank on May 19, 2011 9:38 AMThe query where we are getting error in Standard program AQ20FD==========A2============ for Job
EISSD/REQUISITION 14 / is as follows:
select VBRKBUKRS VBRKFKART VBRKFKDAT VBRKFKTYP VBRKGJAHR VBRKKUNAG VBRKKUNRG VBRKKURRF VBRKVBELN VBRKWAERK VBRP~AUBEL
VBRPAUPOS VBRPFKIMG VBRPKVGR2 VBRPKZWI1 VBRPMATNR VBRPMWSBP VBRPNETWR VBRPPSTYV VBRPVBELN VBRPVGBEL VBRP~VGPOS
VBRPVKBUR VBRPVKGRP VBRPVRKME VBRPWAVWR
into (VBRK-BUKRS , VBRK-FKART , VBRK-FKDAT , VBRK-FKTYP , VBRK-GJAHR , VBRK-KUNAG , VBRK-KUNRG , VBRK-KURRF , VBRK-VBELN
, VBRK-WAERK , VBRP-AUBEL , VBRP-AUPOS , VBRP-FKIMG , VBRP-KVGR2 , VBRP-KZWI1 , VBRP-MATNR , VBRP-MWSBP , VBRP-NETWR
, VBRP-PSTYV , VBRP-VBELN , VBRP-VGBEL , VBRP-VGPOS , VBRP-VKBUR , VBRP-VKGRP , VBRP-VRKME , VBRP-WAVWR )
from ( VBRK
inner join VBRP
on VBRPVBELN = VBRKVBELN )
where VBRK~BUKRS in SP$00004
and VBRK~FKDAT in SP$00001
and VBRK~KUNAG in SP$00002
and VBRK~VBELN in SP$00006
and VBRP~MATNR in SP$00003.
%dbacc = %dbacc - 1.
if %dbacc = 0.
stop.
endif.
check SP$00004.
check SP$00001.
check SP$00002.
check SP$00006.
check SP$00003.
add 1 to %count-VBRK.
%linr-VBRK = '01'.
extract %fg01.
%ext-VBRP01 = 'X'.
extract %fgwrVBRP01.
endselect. -
SQL error in the database when accessing a table.
Hi,
I got below error at production server. Please suggest how to reslove this error.
<br>
<br>
<br>
Runtime Errors DBIF_RSQL_SQL_ERROR
<br>
Exception CX_SY_OPEN_SQL_DB
<br>
Date and Time 02.01.2011 15:55:06
<br>
<br>
<br>
<br>
<br>
Short text
<br>
SQL error in the database when accessing a table.
<br>
<br>
<br>
How to correct the error
<br>
Database error text........: "[10054] TCP Provider: An existing connection was
<br>
forcibly closed by the remote host.
<br>
[10054] Communication link failure"
<br>
Internal call code.........: "[RSQL/INSR/SWFCNTBUF ]"
<br>
Please check the entries in the system log (Transaction SM21).
<br>
<br>
If the error occures in a non-modified SAP program, you may be able to
<br>
find an interim solution in an SAP Note.
<br>
If you have access to SAP Notes, carry out a search with the following
<br>
keywords:
<br>
<br>
"DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"
<br>
"CL_SWF_CNT_FACTORY_SHMEM======CP" or "CL_SWF_CNT_FACTORY_SHMEM======CM001"
<br>
| "ADD_INSTANCE"
<br>
<br>
<br>
Information on where terminated
<br>
Termination occurred in the ABAP program "CL_SWF_CNT_FACTORY_SHMEM======CP" -
<br>
in "ADD_INSTANCE".
<br>
The main program was "SAPMSSY1 ".
<br>
<br>
In the source code you have the termination point in line 16
<br>
of the (Include) program "CL_SWF_CNT_FACTORY_SHMEM======CM001".
<br>
The termination is caused because exception "CX_SY_OPEN_SQL_DB" occurred in
<br>
procedure "ADD_INSTANCE" "(METHOD)", but it was neither handled locally nor
<br>
declared
<br>
in the RAISING clause of its signature.
<br>
<br>
The procedure is in program "CL_SWF_CNT_FACTORY_SHMEM======CP "; its source
<br>
code begins in line
<br>
1 of the (Include program "CL_SWF_CNT_FACTORY_SHMEM======CM001 ".
<br>
<br>
<br>
<br>
Source Code Extract
<br>
<br>
Line
SourceCde
<br>
<br>
1
METHOD add_instance .
<br>
2
<br>
3
data: ls_id type swfcntbuf.
<br>
4
<br>
5
check buffer method - store in local buffer if necessary
<br>
6
retcode = cl_swf_cnt_factory=>add_instance( ibf_por = ibf_por instance = instance ).
<br>
7
<br>
8
CHECK m_buffer_method EQ mc_buffer_shared.
<br>
9
<br>
10
append key to list of tasks to add stored in database table SWFCNTBUF
<br>
11
will be evaluated by build process for shared memory area (UPDATE_BUFFER method)
<br>
12
<br>
13
ls_id-mandt = sy-mandt.
<br>
14
ls_id-id = ibf_por.
<br>
15
<br>
>>>>>
INSERT swfcntbuf CONNECTION r/3*wfcontainer
<br>
17
FROM ls_id.
<br>
18
<br>
19
IF sy-subrc EQ 0.
<br>
20
Commit seems to be necessary always, even if INSERT has failed, to get rid of
<br>
21
database locks
<br>
22
COMMIT CONNECTION r/3*wfcontainer.
<br>
23
ENDIF.
<br>
24
<br>
25
ENDMETHOD.
<br>duplicate here SQL error in the database when accessing a table.
Do not post the same question in more than on forum. -
dear all,
i have done a system copy from production server into quality server. quality was scrapped and freshly installed with SAP then used the DB flush method to carry out the system copy. i had to change the DBS_ORA_SCHEMA in environment variables to SAP<SOURCE SID> from SAPSR3. the sap version is ECC6.0,DB is ORACLE10.2 on WIN NT.
after MMC opened, i get "SQL error in the database when accessing a table" error is coming. in SM21, I am getting "Transaction Canceled 00 671 ( DBIF_RSQL_SQL_ERROR 20081018130339sibqty_QTY_00 SAPSYS 000 )
Database error 8103 at SEL access to table TBTCO
Run-time error "DBIF_RSQL_SQL_ERROR" occurred
Database error 8103 at FET access to table TBTCP
Run-time error "DBIF_RSQL_SQL_ERROR" occurred
> Short dump "081018 130339 sibqty_Q TY_00 " generated
Transaction Canceled 00 671 ( DBIF_RSQL_SQL_ERROR 20081018130339sibqty_QTY_00 SAPSYS 000
> Short dump "081018 130339 sibqty_Q TY_00 " generated
Transaction Canceled 00 671 ( DBIF_RSQL_SQL_ERROR 20081018130339sibqty_QTY_00 SAPSYS 000
Delete session 001 after error 023
Database error 8103 at DEL access to table TMSALOGAR
Run-time error "DBIF_RSQL_SQL_ERROR" occurred
> Short dump "081018 130432 sibqty_Q TY_00 " generated
Database error 8103 at FET access to table SNAP
Run-time error "DBIF_RSQL_SQL_ERROR" occurred
> Short dump "081018 130432 sibqty_Q TY_00 " generated
Transaction Canceled SY 002 ( SQL error in the database when accessing a table. )
Database error 8103 at FET access to table TSP02"
please find the st22 DUMP:
ow to correct the error |
Database error text........: "ORA-08103: object no longer exists"
Internal call code.........: "[RSQL/READ/TBTCO ]"
Please check the entries in the system log (Transaction SM21).
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"
"SAPMSSY2" or "SAPMSSY2"
"INITIATE_JOB_START"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
The exception must either be prevented, caught within proedure
"INITIATE_JOB_START" "(FORM)", or its possible occurrence must be declared in
the
RAISING clause of the procedure.
|
please do me this favor if you know to avoid this problem..
thanks a lot..Hello Anuj,
This is because the COUNT(*) is returning a value which is longer than the INT4 data type it is expecting. If you restrict the selection by introducing a WHERE clause, then you won't get the dump:
DATA: dyn_from TYPE string,
dyn_where TYPE string,
gx_sql_err TYPE REF TO cx_sy_open_sql_error,
gv_text TYPE string.
dyn_from = `DD01L INNER JOIN DD02L ON DD02L~AS4LOCAL = DD01L~AS4LOCAL AND DD02L~AS4VERS = DD01L~AS4VERS`.
dyn_where = `DOMNAME LIKE 'Z%'`.
TRY .
SELECT COUNT(*) FROM (dyn_from) WHERE (dyn_where).
WRITE: / sy-dbcnt NO-GROUPING.
CATCH: cx_sy_open_sql_db INTO gx_sql_err,
cx_sy_dynamic_osql_semantics INTO gx_sql_err,
cx_sy_dynamic_osql_syntax INTO gx_sql_err.
ENDTRY.
IF gx_sql_err IS BOUND.
gv_text = gx_sql_err->get_text( ).
WRITE: / gv_text.
ENDIF.
BR,
Suhas -
Can we implement the custom sql query in CR for joining the two tables
Hi All,
Is there anyway to implement the custom sql query in CR for joining the two tables?
My requirement here is I need to write sql logics for joining the two tables...
Thanks,
GanaIn the Database Expert, expand the Create New Connection folder and browse the subfolders to locate your data source.
Log on to your data source if necessary.
Under your data source, double-click the Add Command node.
In the Add Command to Report dialog box, enter an appropriate query/command for the data source you have opened.
For example:
SELECT
Customer.`Customer ID`,
Customer.`Customer Name`,
Customer.`Last Year's Sales`,
Customer.`Region`,
Customer.`Country`,
Orders.`Order Amount`,
Orders.`Customer ID`,
Orders.`Order Date`
FROM
Customer Customer INNER JOIN Orders Orders ON
Customer.`Customer ID` = Orders.`Customer ID`
WHERE
(Customer.`Country` = 'USA' OR
Customer.`Country` = 'Canada') AND
Customer.`Last Year's Sales` < 10000.
ORDER BY
Customer.`Country` ASC,
Customer.`Region` ASC
Note: The use of double or single quotes (and other SQL syntax) is determined by the database driver used by your report. You must, however, manually add the quotes and other elements of the syntax as you create the command.
Optionally, you can create a parameter for your command by clicking Create and entering information in the Command Parameter dialog box.
For more information about creating parameters, see To create a parameter for a command object.
Click OK.
You are returned to the Report Designer. In the Field Explorer, under Database Fields, a Command table appears listing the database fields you specified.
Note:
To construct the virtual table from your Command, the command must be executed once. If the command has parameters, you will be prompted to enter values for each one.
By default, your command is called Command. You can change its alias by selecting it and pressing F2. -
DBIF_RSQL_SQL_ERROR: SQL error in the database when accessing a table
Hi Gurus,
Im getting DBIF_RSQL_SQL_ERROR: SQL error in the database when accessing a table error while I was importing support pack in the system. This is ERP 6.0 with EHP4 with MS SQL in back ground and I was applying the BASIS SP 04. It was in the TEST scenario and in the SPDD_SPAU_CHECK phase it threw the error.
Short text
SQL error in the database when accessing a table.
What can you do?
Note which actions and input led to the error.
For further help in handling the problem, contact your SAP administrator
You can use the ABAP dump analysis transaction ST22 to view and manage
termination messages, in particular for long term reference.
How to correct the error
Database error text........: "[601] Could not continue scan with NOLOCK due to
data movement."
Internal call code.........: "[RSQL/FTCH/E071 ]"
Please check the entries in the system log (Transaction SM21).
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"
"SAPLSVRT" or "LSVRTU01"
"TR_LAST_IMPORT_OF_OBJECT"
SPAM is ending with the above short dump. I have checked the space availability and it is OK.
Kindly help.
Renju Aravind.Hi,
this error is very often seen in case of a database corruptions. Please follow note 142731 and perform a complete database check. Send the results when they show errors.
Best regards
Clas -
Root cause of "SQL error in the database when accessing a table. "
Dear experts,
I meet this dump "SQL error in the database when accessing a table" when executing a sql.
Sql:
SELECT sesssessno poscrm_serplan_id poscrm_ser_h_id poscrm_ser_i_id
possolution_id sessbundle_id sessdbid sessinstno pos~crm_ordered_prod
sessdbid sessinstno
INTO CORRESPONDING FIELDS OF TABLE et_sess_list
FROM dsvassessadmin AS sess JOIN service_posn_sm AS pos
ON possession_id = sesssessno
FOR ALL ENTRIES IN lt_contractno
WHERE sess~contractno = lt_contractno-contract_no
AND sess~status IN lt_status_range
AND bundle_id IN lt_bundle_id
AND pos~solution_id GT 0
This sql works well in dev system SD7, however, it causes dump in another dev system "SMV".
Can anyone give me any ideas?
ThanksHi Jovito,
This is info from ST22
Short text
SQL error in the database when accessing a table.
What can you do?
Note which actions and input led to the error.
For further help in handling the problem, contact your SAP administrator
You can use the ABAP dump analysis transaction ST22 to view and manage
termination messages, in particular for long term reference.
How to correct the error
Database error text........: "SQL0101N The statement is too long or too
complex. SQLSTATE=54001" Internal call code.........: "[RSQL/OPEN/DSVASSESSADMIN ]"
Please check the entries in the system log (Transaction SM21).
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"
"CL_AGS_SERVICE_SERV===========CP" or "CL_AGS_SERVICE_SERV===========CM018"
"GET_OVS_SESSION_LIST"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
The exception must either be prevented, caught within proedure
"GET_OVS_SESSION_LIST" "(METHOD)", or its possible occurrence must be declared
in the
RAISING clause of the procedure.
To prevent the exception, note the following:
It seems that after translation the native sql is too long. But I think this can be solved. -
PLEASE SEND ME SQL query to list ALL CONSTRAINTS ON EMPLOYEES TABLE FROM OU
PLEASE SEND ME SQL query to list ALL CONSTRAINTS ON EMPLOYEES TABLE FROM OUTSIDE PP SCHEMA INCLUDING SCHEMA NAME AND CONSTraint NAME
Username : PP
Table : EmployeesI think you are looking for below query :
SQL> SHOW USER;
USER is "SCOTT"
SQL> select owner,constraint_name,constraint_type,table_name,r_owner,r_constraint_name
2 from all_constraints
3 where constraint_type='R'
4 and r_constraint_name in (select constraint_name from all_constraints
5 where constraint_type in ('P','U') and table_name='EMP');
OWNER CONSTRAINT_NAME C TABLE_NAME R_OWNER R_CONSTRAINT_NAME
TEST1 ERL_EMP_FK_1 R EMPLOYEE SCOTT PK_EMP
1 row selected.Means, TEST1 user is having a constraint ERL_EMP_FK_1 on his table EMPLOYEE. Which is using PK_EMP (primary key of SCOTT user's 'EMP' [in the query])
Regards
Girish Sharma -
Inbound-Queue SYSFAIL: SQL error in the database when accessing a table
Hi,
we send around 80 IDoc simultaneously, there 15 are stuck.
They all have SYSFAIL in SMQ2 with message: SQL error in the database when accessing a table
I already unlocked the queues and try to resend. Nothing happend!
I ran RSQIWKEX for the single queus but now there are new queues in Status SYSFAIL.
I already checked some entries in forum and blogs, but nothing worked out yet!
Can someone help?! it's urgent!!
brHi, well as mentioned i searched and found this already.
But in ST22 i got error concerning
Laufzeitfehler DBIF_RSQL_SQL_ERROR
Ausnahme CX_SY_OPEN_SQL_DB
So i guess it's something more serious.
Any more ideas?!
Can i simply delete the stucked queues and reporcess them?!
br -
Hi all,
db:oracle 9i
I am facing below query prob.
prob is that query is taking more time 45 min than earliar (10 sec).
please any one suggest me .....
SQL> SELECT MAX (tdar1.ID) ID, tdar1.request_id, tdar1.lolm_transaction_id,
2 tdar1.transaction_version
3 FROM transaction_data_arc tdar1
4 WHERE tdar1.transaction_name ='O96U '
5 AND tdar1.transaction_type = 'REQUEST'
6 AND tdar1.message_type_code ='PCN'
7 AND NOT EXISTS (
8 SELECT NULL
9 FROM transaction_data_arc tdar2
10 WHERE tdar2.request_id = tdar1.request_id
11 AND tdar2.lolm_transaction_id != tdar1.lolm_transaction_id
12 AND tdar2.ID > tdar1.ID)
13 GROUP BY tdar1.request_id,
14 tdar1.lolm_transaction_id,
15 tdar1.transaction_version;
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=17 Card=1 Bytes=42)
1 0 SORT (GROUP BY) (Cost=12 Card=1 Bytes=42)
2 1 FILTER
3 2 TABLE ACCESS (BY INDEX ROWID) OF 'TRANSACTION_DATA_ARC
' (Cost=1 Card=1 Bytes=42)
4 3 INDEX (RANGE SCAN) OF 'NK_TDAR_2' (NON-UNIQUE) (Cost
=3 Card=1)
5 2 TABLE ACCESS (BY INDEX ROWID) OF 'TRANSACTION_DATA_ARC
' (Cost=5 Card=918 Bytes=20196)
6 5 INDEX (RANGE SCAN) OF 'NK_TDAR_7' (NON-UNIQUE) (Cost
=8 Card=4760)prob is that query is taking more time 45 min than earliar (10 sec).Then something must have changed (data growth/stale statistics/...?).
You should post as much details as possible, how and what it is described in the FAQ, see:
*3. How to improve the performance of my query? / My query is running slow*.
When your query takes too long...
How to post a SQL statement tuning request
SQL and PL/SQL FAQ
Also, given your database version, using NOT IN instead of NOT EXISTS might make a difference (but they're not the same).
See: SQL and PL/SQL FAQ -
SQL Query produces different results when inserting into a table
I have an SQL query which produces different results when run as a simple query to when it is run as an INSERT INTO table SELECT ...
The query is:
SELECT mhldr.account_number
, NVL(MAX(DECODE(ap.party_sysid, mhldr.party_sysid,ap.empcat_code,NULL)),'UNKNWN') main_borrower_status
, COUNT(1) num_apps
FROM app_parties ap
SELECT accsta.account_number
, actply.party_sysid
, RANK() OVER (PARTITION BY actply.table_sysid, actply.loanac_latype_code ORDER BY start_date, SYSID) ranking
FROM activity_players actply
, account_status accsta
WHERE 1 = 1
AND actply.table_id (+) = 'ACCGRP'
AND actply.acttyp_code (+) = 'MHLDRM'
AND NVL(actply.loanac_latype_code (+),TO_NUMBER(SUBSTR(accsta.account_number,9,2))) = TO_NUMBER(SUBSTR(accsta.account_number,9,2))
AND actply.table_sysid (+) = TO_NUMBER(SUBSTR(accsta.account_number,1,8))
) mhldr
WHERE 1 = 1
AND ap.lenapp_account_number (+) = TO_NUMBER(SUBSTR(mhldr.account_number,1,8))
GROUP BY mhldr.account_number; The INSERT INTO code:
TRUNCATE TABLE applicant_summary;
INSERT /*+ APPEND */
INTO applicant_summary
( account_number
, main_borrower_status
, num_apps
SELECT mhldr.account_number
, NVL(MAX(DECODE(ap.party_sysid, mhldr.party_sysid,ap.empcat_code,NULL)),'UNKNWN') main_borrower_status
, COUNT(1) num_apps
FROM app_parties ap
SELECT accsta.account_number
, actply.party_sysid
, RANK() OVER (PARTITION BY actply.table_sysid, actply.loanac_latype_code ORDER BY start_date, SYSID) ranking
FROM activity_players actply
, account_status accsta
WHERE 1 = 1
AND actply.table_id (+) = 'ACCGRP'
AND actply.acttyp_code (+) = 'MHLDRM'
AND NVL(actply.loanac_latype_code (+),TO_NUMBER(SUBSTR(accsta.account_number,9,2))) = TO_NUMBER(SUBSTR(accsta.account_number,9,2))
AND actply.table_sysid (+) = TO_NUMBER(SUBSTR(accsta.account_number,1,8))
) mhldr
WHERE 1 = 1
AND ap.lenapp_account_number (+) = TO_NUMBER(SUBSTR(mhldr.account_number,1,8))
GROUP BY mhldr.account_number; When run as a query, this code consistently returns 2 for the num_apps field (for a certain group of accounts), but when run as an INSERT INTO command, the num_apps field is logged as 1. I have secured the tables used within the query to ensure that nothing is changing the data in the underlying tables.
If I run the query as a cursor for loop with an insert into the applicant_summary table within the loop, I get the same results in the table as I get when I run as a stand alone query.
I would appreciate any suggestions for what could be causing this odd behaviour.
Cheers,
Steve
Oracle database details:
Oracle Database 10g Release 10.2.0.2.0 - Production
PL/SQL Release 10.2.0.2.0 - Production
CORE 10.2.0.2.0 Production
TNS for 32-bit Windows: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production
Edited by: stevensutcliffe on Oct 10, 2008 5:26 AM
Edited by: stevensutcliffe on Oct 10, 2008 5:27 AMstevensutcliffe wrote:
Yes, using COUNT(*) gives the same result as COUNT(1).
I have found another example of this kind of behaviour:
Running the following INSERT statements produce different values for the total_amount_invested and num_records fields. It appears that adding the additional aggregation (MAX(amount_invested)) is causing problems with the other aggregated values.
Again, I have ensured that the source data and destination tables are not being accessed / changed by any other processes or users. Is this potentially a bug in Oracle?Just as a side note, these are not INSERT statements but CTAS statements.
The only non-bug explanation for this behaviour would be a potential query rewrite happening only under particular circumstances (but not always) in the lower integrity modes "trusted" or "stale_tolerated". So if you're not aware of any corresponding materialized views, your QUERY_REWRITE_INTEGRITY parameter is set to the default of "enforced" and your explain plan doesn't show any "MAT_VIEW REWRITE ACCESS" lines, I would consider this as a bug.
Since you're running on 10.2.0.2 it's not unlikely that you hit one of the various "wrong result" bugs that exist(ed) in Oracle. I'm aware of a particular one I've hit in 10.2.0.2 when performing a parallel NESTED LOOP ANTI operation which returned wrong results, but only in parallel execution. Serial execution was showing the correct results.
If you're performing parallel ddl/dml/query operations, try to do the same in serial execution to check if it is related to the parallel feature.
You could also test if omitting the "APPEND" hint changes anything but still these are just workarounds for a buggy behaviour.
I suggest to consider installing the latest patch set 10.2.0.4 but this requires thorough testing because there were (more or less) subtle changes/bugs introduced with [10.2.0.3|http://oracle-randolf.blogspot.com/2008/02/nasty-bug-introduced-with-patch-set.html] and [10.2.0.4|http://oracle-randolf.blogspot.com/2008/04/overview-of-new-and-changed-features-in.html].
You could also open a SR with Oracle and clarify if there is already a one-off patch available for your 10.2.0.2 platform release. If not it's quite unlikely that you are going to get a backport for 10.2.0.2.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Query Execution time differs when executed inside a procedure
Hi All,
Oracle 10.2.0
Windows 2003 server
We have a query that runs faster when it is executed as a seperate query.
But its taking time when it is executed as a procedure.
Please advice to find the problem.
TIA,ORCLDB wrote:
Hi All,
Oracle 10.2.0
Windows 2003 server
We have a query that runs faster when it is executed as a seperate query.
But its taking time when it is executed as a procedure.
Please advice to find the problem.
TIA,You should be able to enable a 10046 trace at level 12 for each execution environment, and examine the STAT lines in the raw trace files to see how the execution plans differ, and if bind variables are used, to see if those bind variables are defined as an incorrect data type. Search the forums to see how to enable a 10046 trace and read the resulting trace files.
Here is a post which shows how to read the trace files. I probably posted a couple times in the past how to enable a 10046 trace:
Re: some 10046 traceing questions.....
Are you running 10.2.0.1, 10.2.0.2, 10.2.0.3, or 10.2.0.4?
Charles Hooper
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc.
Maybe you are looking for
-
wait wait wait, I must be making a stupid mistake I set my new song tempo at 80.. I make sure its that way in the transport bar, etc etc I audition a loop, like it, drop it in timeline it plays the same tempo as it did in audition. I go to the tempo
-
We just purchased Final Cut Express, and we own a Canon Gl2 as our camera. I've tried every dv-ntsc preset in easy setup, and no matter what FCE doesn't recognize my camera. I have tried different firewire cables and there is no other fire wire hard
-
Formatting a date value in Reporting Services
0 down vote favorite I am a bit rusty and would be very grateful if you could help. I am using Reporting Services. I have a simple report that gives the date_ordered value. Unfortunately, when I ORDER BY date_ordered, it sorts the date by number of d
-
How to set a process with more than 10 item values to be changed?
I am trying to make a "default" button where it resets the Column checkboxes to its original state but I have more than 10 iems and I cant fill them all in the 10 slots that they have. Anyone have any ideas? thanks. For example I have columns 1-20 an
-
Hi, I'm trying to print a 1mm X 1mm grid in a paper. I'm using Java2D to print the lines. This is the code snippet which draws the lines: /** Pixels/millimeter ratio */ public final static double PRINT_PIXELS_PER_MILLIMETER = (72.00 / 25.40