ORA-01467
Hi All,
I am getting following error with the pivoting query.
Declare
ERROR at line 1:
ORA-01467: sort key too long
ORA-06512: at line 30
On some forum I got that this error is related with Datablock size and
also that decode and case statment have limitation of 255 clauses ina
query.
my query is as follows.
insert into gtt_sample_component_matrix1
( submission_id
, sample_id
, C1
, C1_RESULT_ID
, C1_NUMBER_VALUE
, C2
, C2_RESULT_ID
, C2_NUMBER_VALUE
, C66
, C66_RESULT_ID
, C66_NUMBER_VALUE
select submission_id
, sample_id
, max( decode( ref_component , 'C1_1149_1 component' , text_value )) C1
, max( decode( ref_component , 'C1_1149_1 component' , C1_RESULT_ID )) C1
, max( decode( ref_component , 'C1_1149_1 component' , C1_NUMBER_VALUE )) C1
, max( decode( ref_component , 'C1_1149_2 component' , text_value )) C2
, max( decode( ref_component , 'C1_1149_2 component' , C2_RESULT_ID )) C2
, max( decode( ref_component , 'C1_1149_2 component' , C2_NUMBER_VALUE )) C2
, max( decode( ref_component , 'C4_OQ Test Operation' , text_value )) C66
, max( decode( ref_component , 'C4_OQ Test Operation' ,C66_RESULT_ID )) C66
, max( decode( ref_component , 'C4_OQ Test Operation' , C66_NUMBER_VALUE )) C66
from gtt_submission_rs group by submission_id, sample_id
OR could any one suggest any alternative logic for pivoting.
Oracle db version+release ?
How many columns are included in your select statement ?
Nicolas.
Similar Messages
-
Error ORA-01467: sort key too long
Hi. I have just come across the error ORA-01467: sort key too long .
In the Oracle documentation, the 2 line
description of this error basically says that there may be too many columns
or group functions in the query, so I need to reduce the number of columns
in the query.
Here's the problem. The documentation does not say how many the limit is.
The query is quite complex, I suppose, but I don't see why it should be a
problem. In a nutshell, the main table has 3 text fields (which are the
index) and 154 floats. The query joins one of the text fields to another
table to get a lookup value and selects this out, along with the other two
text fields and the SUM of the numeric fields. The query groups by the two
text fields and the lookup.
I guess I saw this when I was using MS SQL Server 6.5 and tried to sum more
than 125 columns, but that went away in SQL Server 7. I am using Oracle 8
at this point but need to support Oracle 7, too.
I guess what I am looking for (at least) is the maximum number of columns
that can be in a grouping/summing query. I'd also like to know if this can
be worked around by changing a setting on the server, something to set the
maximum number of sums to 1000, perhaps? I am fine with working around this
in my software if I need to, as I have done previously (I took the first 125
sums into a temp table, then the next 125, etc. and joined the resulting
tables to get my results), but would really like to get a workaround that
was server-based, if possible.
Thanks for your help!
nullHi. I have just come across the error ORA-01467: sort key too long .
In the Oracle documentation, the 2 line
description of this error basically says that there may be too many columns
or group functions in the query, so I need to reduce the number of columns
in the query.
Here's the problem. The documentation does not say how many the limit is.
The query is quite complex, I suppose, but I don't see why it should be a
problem. In a nutshell, the main table has 3 text fields (which are the
index) and 154 floats. The query joins one of the text fields to another
table to get a lookup value and selects this out, along with the other two
text fields and the SUM of the numeric fields. The query groups by the two
text fields and the lookup.
I guess I saw this when I was using MS SQL Server 6.5 and tried to sum more
than 125 columns, but that went away in SQL Server 7. I am using Oracle 8
at this point but need to support Oracle 7, too.
I guess what I am looking for (at least) is the maximum number of columns
that can be in a grouping/summing query. I'd also like to know if this can
be worked around by changing a setting on the server, something to set the
maximum number of sums to 1000, perhaps? I am fine with working around this
in my software if I need to, as I have done previously (I took the first 125
sums into a temp table, then the next 125, etc. and joined the resulting
tables to get my results), but would really like to get a workaround that
was server-based, if possible.
Thanks for your help!
null -
ORA-01467: sort key too long
Hi,
I am trying to run the below query in toad but getting the error "ORA-01467: sort key too long".
SELECT :o,
:o,
MSD,
1,
SUM(FLAG),
DECODE(SUM(FLAGCOLOR),0,0,1),
SUM(DECODE(SIGN(Tiefool), -1,'',Tiefool)),
SUM(DECODE(SIGN(Tiegreen), -1,'',Tiegreen)),
SUM(DECODE(SIGN(TiesacTotaru), -1,'',TiesacTotaru)),
SUM(DECODE(SIGN(Tiesaccfaru), -1,'',Tiesaccfaru)),
SUM(DECODE(SIGN(Tiel), -1,'',Tiel)),
SUM(DECODE(SIGN(Tiemannj), -1,'',Tiemannj)),
SUM(DECODE(SIGN(HiYaNo57), -1,'',HiYaNo57)),
SUM(DECODE(SIGN(HiYaNoAttOIRHoLad), -1,'',HiYaNoAttOIRHoLad)),
SUM(DECODE(SIGN(HiYaNoAttOIRHomannj), -1,'',HiYaNoAttOIRHomannj)),
SUM(DECODE(SIGN(HiYaNoAttOIRHosmrlone), -1,'',HiYaNoAttOIRHosmrlone)),
SUM(DECODE(SIGN(HiYaNoAttOSwHomannj), -1,'',HiYaNoAttOSwHomannj)),
SUM(DECODE(SIGN(HiYaNoFlOIRHoCs57jFlr),-1,'',HiYaNoFlOIRHoCs57jFlr)),
SUM(DECODE(SIGN(HiYaNoFlOIRHoCs57Re_00), -1,'',HiYaNoFlOIRHoCs57Re_00)),
SUM(DECODE(SIGN(HiYaNoFlOIRHoCs57Re_01), -1,'',HiYaNoFlOIRHoCs57Re_01)),
SUM(DECODE(SIGN(HiYaNoFlOIRHoCs57Ue_00), -1,'',HiYaNoFlOIRHoCs57Ue_00)),
SUM(DECODE(SIGN(HiYaNoFlOIRHoLadG_00), -1,'',HiYaNoFlOIRHoLadG_00)),
SUM(DECODE(SIGN(HiYaNoFlOIRHoLadR_00), -1,'',HiYaNoFlOIRHoLadR_00)),
SUM(DECODE(SIGN(HiYaNoFlOIRHoLadR_01), -1,'',HiYaNoFlOIRHoLadR_01)),
SUM(DECODE(SIGN(HiYaNoFlOIRHoLadU_00), -1,'',HiYaNoFlOIRHoLadU_00)),
SUM(DECODE(SIGN(HiYaNoFlOIRHomannj_00), -1,'',HiYaNoFlOIRHomannj_00)),
SUM(DECODE(SIGN(HiYaNoFlOIRHomannj_01), -1,'',HiYaNoFlOIRHomannj_01)),
SUM(DECODE(SIGN(HiYaNoFlOIRHomannj_02), -1,'',HiYaNoFlOIRHomannj_02)),
SUM(DECODE(SIGN(HiYaNoFlOIRHomannj_03), -1,'',HiYaNoFlOIRHomannj_03)),
SUM(DECODE(SIGN(HiYaNoFlOIRHosmr_00), -1,'',HiYaNoFlOIRHosmr_00)),
SUM(DECODE(SIGN(HiYaNoFlOIRHosmr_01), -1,'',HiYaNoFlOIRHosmr_01)),
SUM(DECODE(SIGN(HiYaNoFlOIRHosmr_02), -1,'',HiYaNoFlOIRHosmr_02)),
SUM(DECODE(SIGN(HiYaNoFlOIRHosmr_03), -1,'',HiYaNoFlOIRHosmr_03)),
SUM(DECODE(SIGN(HiYaNoFlOSwHomannj_00), -1,'',HiYaNoFlOSwHomannj_00)),
SUM(DECODE(SIGN(HiYaNoFlOSwHomannj_01), -1,'',HiYaNoFlOSwHomannj_01)),
SUM(DECODE(SIGN(HiYaNoFlOSwHomannj_02), -1,'',HiYaNoFlOSwHomannj_02)),
SUM(DECODE(SIGN(HiYaNoFlOSwHomannj_03), -1,'',HiYaNoFlOSwHomannj_03)),
SUM(DECODE(SIGN(HiYaNoOIRCckOldCh), -1,'',HiYaNoOIRCckOldCh)),
SUM(DECODE(SIGN(HiYaNoOIRCcq), -1,'',HiYaNoOIRCcq)),
SUM(DECODE(SIGN(HiYaNoOIRHocAl_00), -1,'',HiYaNoOIRHocAl_00)),
SUM(DECODE(SIGN(HiYaNoOIRHokOldC_00), -1,'',HiYaNoOIRHokOldC_00)),
SUM(DECODE(SIGN(HiYaNoOIRHokOldC_01), -1,'',HiYaNoOIRHokOldC_01)),
SUM(DECODE(SIGN(HiYaNoOIRHoq), -1,'',HiYaNoOIRHoq)),
SUM(DECODE(SIGN(HiYatoyCs57), -1,'',HiYatoyCs57)),
SUM(DECODE(SIGN(HiYatoyLad), -1,'',HiYatoyLad)),
SUM(DECODE(SIGN(HiYatoymannj), -1,'',HiYatoymannj)),
SUM(DECODE(SIGN(HiYatoysmrlone),-1,'',HiYatoysmrlone)),
SUM(DECODE(SIGN(HiYaNoplymannj), -1,'',HiYaNoplymannj)),
SUM(DECODE(SIGN(redAtt), -1,'',redAtt)),
SUM(DECODE(SIGN(NoYaNoOutIratHoAtt), -1,'',NoYaNoOutIratHoAtt)),
SUM(DECODE(SIGN(vavaYakcttntodef), -1,'',vavaYakcttntodef)),
SUM(DECODE(SIGN(vavaYakcttntoMan), -1,'',vavaYakcttntoMan)),
SUM(DECODE(SIGN(vavaYaNoddvac), -1,'',vavaYaNoddvac)),
SUM(DECODE(SIGN(vavaYaNordvac), -1,'',vavaYaNordvac)),
SUM(DECODE(SIGN(vavaYasalRlcTotPktThp), -1,'',vavaYasalRlcTotPktThp)),
SUM(DECODE(SIGN(vavaYasalRlccfPktThp),-1,'',vavaYasalRlccfPktThp)),
SUM(DECODE(SIGN(vavaYamilRlcTotPktThp), -1,'',vavaYamilRlcTotPktThp)),
SUM(DECODE(SIGN(vavaYamilRlccfPktThp), -1,'',vavaYamilRlccfPktThp)),
SUM(DECODE(SIGN(MyYaNoauwcupytr00),-1,'',MyYaNoauwcupytr00)),
SUM(DECODE(SIGN(MyYaNoauwcupytr01),-1,'',MyYaNoauwcupytr01)),
SUM(DECODE(SIGN(MyYaNoauwcupytr02),-1,'',MyYaNoauwcupytr02)),
SUM(DECODE(SIGN(MyYaNoauwcupytr03),-1,'',MyYaNoauwcupytr03)),
SUM(DECODE(SIGN(MyYaNoauwcupytr04),-1,'',MyYaNoauwcupytr04)),
SUM(DECODE(SIGN(MyYaNoauwcupytr05),-1,'',MyYaNoauwcupytr05)),
SUM(DECODE(SIGN(MyYaNoauwcupytr06),-1,'',MyYaNoauwcupytr06)),
SUM(DECODE(SIGN(MyYaNoauwcupytr07),-1,'',MyYaNoauwcupytr07)),
SUM(DECODE(SIGN(MyYaNoauwcupytr08),-1,'',MyYaNoauwcupytr08)),
SUM(DECODE(SIGN(MyYaNoauwcupytr09),-1,'',MyYaNoauwcupytr09)),
SUM(DECODE(SIGN(MyYaNoauwcupytr10),-1,'',MyYaNoauwcupytr10)),
SUM(DECODE(SIGN(MyYaNoauwcupytr11),-1,'',MyYaNoauwcupytr11)),
SUM(DECODE(SIGN(MyYaNoauwcupytr12),-1,'',MyYaNoauwcupytr12)),
SUM(DECODE(SIGN(MyYaNoauwcupytr13),-1,'',MyYaNoauwcupytr13)),
SUM(DECODE(SIGN(MyYaNoauwcupytr14),-1,'',MyYaNoauwcupytr14)),
SUM(DECODE(SIGN(MyYaNoauwcupytr15),-1,'',MyYaNoauwcupytr15)),
SUM(DECODE(SIGN(MyYaNoravmyfFra00),-1,'',MyYaNoravmyfFra00)),
SUM(DECODE(SIGN(MyYaNoravmyfFra01),-1,'',MyYaNoravmyfFra01)),
SUM(DECODE(SIGN(MyYaNoravmyfFra02),-1,'',MyYaNoravmyfFra02)),
SUM(DECODE(SIGN(MyYaNoravmyfFra03),-1,'',MyYaNoravmyfFra03)),
SUM(DECODE(SIGN(MyYaNoravmyfFra04),-1,'',MyYaNoravmyfFra04)),
SUM(DECODE(SIGN(MyYaNoravmyfFra05),-1,'',MyYaNoravmyfFra05)),
SUM(DECODE(SIGN(MyYaNoravmyfFra06),-1,'',MyYaNoravmyfFra06)),
SUM(DECODE(SIGN(MyYaNoravmyfFra07),-1,'',MyYaNoravmyfFra07)),
SUM(DECODE(SIGN(MyYaNoravmyfFra08),-1,'',MyYaNoravmyfFra08)),
SUM(DECODE(SIGN(MyYaNoravmyfFra09),-1,'',MyYaNoravmyfFra09)),
SUM(DECODE(SIGN(MyYaNoravmyfFra10),-1,'',MyYaNoravmyfFra10)),
SUM(DECODE(SIGN(MyYaNoravmyfFra11),-1,'',MyYaNoravmyfFra11)),
SUM(DECODE(SIGN(MyYaNoravmyfFra12),-1,'',MyYaNoravmyfFra12)),
SUM(DECODE(SIGN(MyYaNoravmyfFra13),-1,'',MyYaNoravmyfFra13)),
SUM(DECODE(SIGN(MyYaNoravmyfFra14),-1,'',MyYaNoravmyfFra14)),
SUM(DECODE(SIGN(MyYaNoravmyfFra15),-1,'',MyYaNoravmyfFra15)),
SUM(DECODE(SIGN(MyYamigtumytr00), -1,'',MyYamigtumytr00)),
SUM(DECODE(SIGN(MyYamigtumytr01), -1,'',MyYamigtumytr01)),
SUM(DECODE(SIGN(MyYamigtumytr02), -1,'',MyYamigtumytr02)),
SUM(DECODE(SIGN(MyYamigtumytr03), -1,'',MyYamigtumytr03)),
SUM(DECODE(SIGN(MyYamigtumytr04), -1,'',MyYamigtumytr04)),
SUM(DECODE(SIGN(MyYamigtumytr05), -1,'',MyYamigtumytr05)),
SUM(DECODE(SIGN(MyYamigtumytr06), -1,'',MyYamigtumytr06)),
SUM(DECODE(SIGN(MyYamigtumytr07), -1,'',MyYamigtumytr07)),
SUM(DECODE(SIGN(MyYamigtumytr08), -1,'',MyYamigtumytr08)),
SUM(DECODE(SIGN(MyYamigtumytr09), -1,'',MyYamigtumytr09)),
SUM(DECODE(SIGN(MyYamigtumytr10), -1,'',MyYamigtumytr10)),
SUM(DECODE(SIGN(MyYamigtumytr11), -1,'',MyYamigtumytr11)),
SUM(DECODE(SIGN(MyYamigtumytr12), -1,'',MyYamigtumytr12)),
SUM(DECODE(SIGN(MyYamigtumytr13), -1,'',MyYamigtumytr13)),
SUM(DECODE(SIGN(MyYamigtumytr14), -1,'',MyYamigtumytr14)),
SUM(DECODE(SIGN(MyYamigtumytr15), -1,'',MyYamigtumytr15)),
SUM(DECODE(SIGN(MyYaSUMlolytr00), -1,'',MyYaSUMlolytr00)),
SUM(DECODE(SIGN(MyYaSUMlolytr01), -1,'',MyYaSUMlolytr01)),
SUM(DECODE(SIGN(MyYaSUMlolytr02), -1,'',MyYaSUMlolytr02)),
SUM(DECODE(SIGN(MyYaSUMlolytr03), -1,'',MyYaSUMlolytr03)),
SUM(DECODE(SIGN(MyYaSUMlolytr04), -1,'',MyYaSUMlolytr04)),
SUM(DECODE(SIGN(MyYaSUMlolytr05), -1,'',MyYaSUMlolytr05)),
SUM(DECODE(SIGN(MyYaSUMlolytr06), -1,'',MyYaSUMlolytr06)),
SUM(DECODE(SIGN(MyYaSUMlolytr07), -1,'',MyYaSUMlolytr07)),
SUM(DECODE(SIGN(MyYaSUMlolytr08), -1,'',MyYaSUMlolytr08)),
SUM(DECODE(SIGN(MyYaSUMlolytr09), -1,'',MyYaSUMlolytr09)),
SUM(DECODE(SIGN(MyYaSUMlolytr10), -1,'',MyYaSUMlolytr10)),
SUM(DECODE(SIGN(MyYaSUMlolytr11), -1,'',MyYaSUMlolytr11)),
SUM(DECODE(SIGN(MyYaSUMlolytr12), -1,'',MyYaSUMlolytr12)),
SUM(DECODE(SIGN(MyYaSUMlolytr13), -1,'',MyYaSUMlolytr13)),
SUM(DECODE(SIGN(MyYaSUMlolytr14), -1,'',MyYaSUMlolytr14)),
SUM(DECODE(SIGN(MyYaSUMlolytr15), -1,'',MyYaSUMlolytr15)),
SUM(DECODE(SIGN(MyYaSUMgrtytr00), -1,'',MyYaSUMgrtytr00)),
SUM(DECODE(SIGN(MyYaSUMgrtytr01), -1,'',MyYaSUMgrtytr01)),
SUM(DECODE(SIGN(MyYaSUMgrtytr02), -1,'',MyYaSUMgrtytr02)),
SUM(DECODE(SIGN(MyYaSUMgrtytr03), -1,'',MyYaSUMgrtytr03)),
SUM(DECODE(SIGN(MyYaSUMgrtytr04), -1,'',MyYaSUMgrtytr04)),
SUM(DECODE(SIGN(MyYaSUMgrtytr05), -1,'',MyYaSUMgrtytr05)),
SUM(DECODE(SIGN(MyYaSUMgrtytr06), -1,'',MyYaSUMgrtytr06)),
SUM(DECODE(SIGN(MyYaSUMgrtytr07), -1,'',MyYaSUMgrtytr07)),
SUM(DECODE(SIGN(MyYaSUMgrtytr08), -1,'',MyYaSUMgrtytr08)),
SUM(DECODE(SIGN(MyYaSUMgrtytr09), -1,'',MyYaSUMgrtytr09)),
SUM(DECODE(SIGN(MyYaSUMgrtytr10), -1,'',MyYaSUMgrtytr10)),
SUM(DECODE(SIGN(MyYaSUMgrtytr11), -1,'',MyYaSUMgrtytr11)),
SUM(DECODE(SIGN(MyYaSUMgrtytr12), -1,'',MyYaSUMgrtytr12)),
SUM(DECODE(SIGN(MyYaSUMgrtytr13), -1,'',MyYaSUMgrtytr13)),
SUM(DECODE(SIGN(MyYaSUMgrtytr14), -1,'',MyYaSUMgrtytr14)),
SUM(DECODE(SIGN(MyYaSUMgrtytr15), -1,'',MyYaSUMgrtytr15)),
SUM(DECODE(SIGN(MyYamigcfvw00),-1,'',MyYamigcfvw00)),
SUM(DECODE(SIGN(MyYamigcfvw01),-1,'',MyYamigcfvw01)),
SUM(DECODE(SIGN(MyYamigcfvw02),-1,'',MyYamigcfvw02)),
SUM(DECODE(SIGN(MyYamigcfvw03),-1,'',MyYamigcfvw03)),
SUM(DECODE(SIGN(MyYamigcfvw04),-1,'',MyYamigcfvw04)),
SUM(DECODE(SIGN(MyYamigcfvw05),-1,'',MyYamigcfvw05)),
SUM(DECODE(SIGN(MyYamigcfvw06),-1,'',MyYamigcfvw06)),
SUM(DECODE(SIGN(MyYamigcfvw07),-1,'',MyYamigcfvw07)),
SUM(DECODE(SIGN(MyYamigcfvw08),-1,'',MyYamigcfvw08)),
SUM(DECODE(SIGN(MyYamigcfvw09),-1,'',MyYamigcfvw09)),
SUM(DECODE(SIGN(MyYamigcfvw10),-1,'',MyYamigcfvw10)),
SUM(DECODE(SIGN(MyYamigcfvw11),-1,'',MyYamigcfvw11)),
SUM(DECODE(SIGN(MyYamigcfvw12),-1,'',MyYamigcfvw12)),
SUM(DECODE(SIGN(MyYamigcfvw13),-1,'',MyYamigcfvw13)),
SUM(DECODE(SIGN(MyYamigcfvw14),-1,'',MyYamigcfvw14)),
SUM(DECODE(SIGN(MyYamigcfvw15),-1,'',MyYamigcfvw15)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr00), -1,'',MyYaSUMNoOfcfsytr00)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr01), -1,'',MyYaSUMNoOfcfsytr01)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr02), -1,'',MyYaSUMNoOfcfsytr02)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr03), -1,'',MyYaSUMNoOfcfsytr03)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr04), -1,'',MyYaSUMNoOfcfsytr04)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr05), -1,'',MyYaSUMNoOfcfsytr05)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr06), -1,'',MyYaSUMNoOfcfsytr06)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr07), -1,'',MyYaSUMNoOfcfsytr07)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr08), -1,'',MyYaSUMNoOfcfsytr08)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr09), -1,'',MyYaSUMNoOfcfsytr09)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr10), -1,'',MyYaSUMNoOfcfsytr10)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr11), -1,'',MyYaSUMNoOfcfsytr11)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr12), -1,'',MyYaSUMNoOfcfsytr12)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr13), -1,'',MyYaSUMNoOfcfsytr13)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr14), -1,'',MyYaSUMNoOfcfsytr14)),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr15), -1,'',MyYaSUMNoOfcfsytr15)),
SUM(DECODE(SIGN(MyYamiiitum00),-1,'',MyYamiiitum00)),
SUM(DECODE(SIGN(MyYamiiitum01),-1,'',MyYamiiitum01)),
SUM(DECODE(SIGN(MyYamiiitum02),-1,'',MyYamiiitum02)),
SUM(DECODE(SIGN(MyYamiiitum03),-1,'',MyYamiiitum03)),
SUM(DECODE(SIGN(MyYamiiitum04),-1,'',MyYamiiitum04)),
SUM(DECODE(SIGN(MyYamiiitum05),-1,'',MyYamiiitum05)),
SUM(DECODE(SIGN(MyYamiiitum06),-1,'',MyYamiiitum06)),
SUM(DECODE(SIGN(MyYamiiitum07),-1,'',MyYamiiitum07)),
SUM(DECODE(SIGN(MyYamiiitum08),-1,'',MyYamiiitum08)),
SUM(DECODE(SIGN(MyYamiiitum09),-1,'',MyYamiiitum09)),
SUM(DECODE(SIGN(MyYamiiitum10),-1,'',MyYamiiitum10)),
SUM(DECODE(SIGN(MyYamiiitum11),-1,'',MyYamiiitum11)),
SUM(DECODE(SIGN(MyYamiiitum12),-1,'',MyYamiiitum12)),
SUM(DECODE(SIGN(MyYamiiitum13),-1,'',MyYamiiitum13)),
SUM(DECODE(SIGN(MyYamiiitum14),-1,'',MyYamiiitum14)),
SUM(DECODE(SIGN(MyYamiiitum15),-1,'',MyYamiiitum15)),
SUM(DECODE(SIGN(Cart),-1,'',Cart)),
SUM(DECODE(SIGN(Carg),-1,'',Carg)),
SUM(DECODE(SIGN(Carw), -1,'',Carw)),
SUM(DECODE(SIGN(Cars), -1,'',Cars)),
SUM(DECODE(SIGN(Carx),-1,'',Carx)),
SUM(DECODE(SIGN(Cara), -1,'',Cara)),
SUM(DECODE(SIGN(Carxs), -1,'',Carxs)),
SUM(DECODE(SIGN(Carq),-1,'',Carq)),
SUM(DECODE(SIGN(Carp),-1,'',Carp)),
SUM(DECODE(SIGN(Cark),-1,'',Cark)),
SUM(DECODE(SIGN(Carg), -1,'',Carg)),
SUM(DECODE(SIGN(Carn), -1,'',Carn)),
SUM(DECODE(SIGN(CarYgh), -1,'',CarYgh)),
SUM(DECODE(SIGN(Carty), -1,'',Carty)),
SUM(DECODE(SIGN(Carzx), -1,'',Carzx)),
SUM(DECODE(SIGN(asdef), -1,'',asdef)),
SUM(DECODE(SIGN(toyYaIncup), -1,'',toyYaIncup)),
SUM(DECODE(SIGN(toyYaInLostcup), -1,'',toyYaInLostcup)),
SUM(DECODE(SIGN(toyYaInOutOfwcup),-1,'',toyYaInOutOfwcup)),
SUM(DECODE(SIGN(toyYaOutcup), -1,'',toyYaOutcup)),
SUM(DECODE(SIGN(manYaNoddSdulk128), -1,'',manYaNoddSdulk128)),
SUM(DECODE(SIGN(manYaNoddSdulk256), -1,'',manYaNoddSdulk256)),
SUM(DECODE(SIGN(manYaNoddSdulk64), -1,'',manYaNoddSdulk64)),
SUM(DECODE(SIGN(fudYaDlfd12PsStrMwm128),-1,'',fudYaDlfd12PsStrMwm128)),
SUM(DECODE(SIGN(fudYaDlfd12PsStrMwm256),-1,'',fudYaDlfd12PsStrMwm256)),
SUM(DECODE(SIGN(fudYaDlfd12PsStrMwms64),-1,'',fudYaDlfd12PsStrMwms64)),
SUM(DECODE(SIGN(fudYaMwmsghCongTo), -1,'',fudYaMwmsghCongTo)),
SUM(DECODE(SIGN(fudYaMwmscttntodef), -1,'',fudYaMwmscttntodef)),
SUM(DECODE(SIGN(fudYaMwmscttntoMan), -1,'',fudYaMwmscttntoMan)),
SUM(DECODE(SIGN(fudYaNoamMwms09),-1,'',fudYaNoamMwms09)),
SUM(DECODE(SIGN(fudYaNoFldMwmsSesLackRnRe),-1,'',fudYaNoFldMwmsSesLackRnRe)),
SUM(DECODE(SIGN(fudYaNoFldMwmsSesLackTnRe),-1,'',fudYaNoFldMwmsSesLackTnRe)),
SUM(DECODE(SIGN(fudYaNoqessMwms09),-1,'',fudYaNoqessMwms09)),
SUM(DECODE(SIGN(fudYaNoqMwmsSesrr), -1,'',fudYaNoqMwmsSesrr)),
SUM(DECODE(SIGN(fudYaNoteMwmsSesStop), -1,'',fudYaNoteMwmsSesStop)),
SUM(DECODE(SIGN(fudYaslesMwmslg), -1,'',fudYaslesMwmslg)),
SUM(DECODE(SIGN(fudYaslesPsStrMwms64Rl),-1,'',fudYaslesPsStrMwms64Rl)),
SUM(DECODE(SIGN(fudYasPsStrMwms128RlcU),-1,'',fudYasPsStrMwms128RlcU)),
SUM(DECODE(SIGN(fudYasPsStrMwms256RlcU),-1,'',fudYasPsStrMwms256RlcU)),
SUM(DECODE(SIGN(fudYamiwmslg), -1,'',fudYamiwmslg)),
SUM(DECODE(SIGN(fudYamisStrMwms128RlcUs),-1,'',fudYamisStrMwms128RlcUs)),
SUM(DECODE(SIGN(fudYamisStrMwms256RlcUs),-1,'',fudYamisStrMwms256RlcUs)),
SUM(DECODE(SIGN(fudYamisStrMwms64RlcUse),-1,'',fudYamisStrMwms64RlcUse)),
SUM(DECODE(SIGN(cosYaAgpsam), -1,'',cosYaAgpsam)),
SUM(DECODE(SIGN(cosYaAgpsqQosNotOk), -1,'',cosYaAgpsqQosNotOk)),
SUM(DECODE(SIGN(cosYaAgpsqQosOk), -1,'',cosYaAgpsqQosOk)),
SUM(DECODE(SIGN(cosYaghIdam), -1,'',cosYaghIdam)),
SUM(DECODE(SIGN(cosYaghIdqQosNotOk),-1,'',cosYaghIdqQosNotOk)),
SUM(DECODE(SIGN(cosYaghIdqQosOk), -1,'',cosYaghIdqQosOk)),
SUM(DECODE(SIGN(cosYaRttam), -1,'',cosYaRttam)),
SUM(DECODE(SIGN(cosYaRttqQosNotOk), -1,'',cosYaRttqQosNotOk)),
SUM(DECODE(SIGN(cosYaRttqQosOk), -1,'',cosYaRttqQosOk)),
SUM(DECODE(SIGN(app_YaFaultycrwlocks), -1,'',app_YaFaultycrwlocks)),
SUM(DECODE(SIGN(app_YaFrmNoOfDiscappcup), -1,'',app_YaFrmNoOfDiscappcup)),
SUM(DECODE(SIGN(app_YaNoRecsheAccqess), -1,'',app_YaNoRecsheAccqess)),
SUM(DECODE(SIGN(app_Yacrwlocks), -1,'',app_Yacrwlocks)),
SUM(DECODE(SIGN(galAttNonloveIeFqHoCsC_00), -1,'',galAttNonloveIeFqHoCsC_00)),
SUM(DECODE(SIGN(galAttNonloveIeFqHoCsS_00), -1,'',galAttNonloveIeFqHoCsS_00)),
SUM(DECODE(SIGN(galAttNonloveIeFqHoPsI_00), -1,'',galAttNonloveIeFqHoPsI_00)),
SUM(DECODE(SIGN(galAttNonloveIeFqHoPsI_01), -1,'',galAttNonloveIeFqHoPsI_01)),
SUM(DECODE(SIGN(galAttNonloveIeFqHoStr_00), -1,'',galAttNonloveIeFqHoStr_00)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoFa_00), -1,'',galFlNonloveIeFqHoFa_00)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoFa_01), -1,'',galFlNonloveIeFqHoFa_01)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoFa_02), -1,'',galFlNonloveIeFqHoFa_02)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoFa_03), -1,'',galFlNonloveIeFqHoFa_03)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoFa_04), -1,'',galFlNonloveIeFqHoFa_04)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoRe_00), -1,'',galFlNonloveIeFqHoRe_00)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoRe_01), -1,'',galFlNonloveIeFqHoRe_01)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoRe_02), -1,'',galFlNonloveIeFqHoRe_02)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoRe_03), -1,'',galFlNonloveIeFqHoRe_03)),
SUM(DECODE(SIGN(galFlNonloveIeFqHoRe_04), -1,'',galFlNonloveIeFqHoRe_04)),
SUM(DECODE(SIGN(galNoAttOCnhhoCsNonmannj), -1,'',galNoAttOCnhhoCsNonmannj)),
SUM(DECODE(SIGN(galNoAttOCnhhoPsdeeRe_00), -1,'',galNoAttOCnhhoPsdeeRe_00)),
SUM(DECODE(SIGN(galNoAttOutCnhhomannj), -1,'',galNoAttOutCnhhomannj)),
SUM(DECODE(SIGN(galNoqOCnhhoCsNonmannj),-1,'',galNoqOCnhhoCsNonmannj)),
SUM(DECODE(SIGN(galNoqOutCnhhomannj), -1,'',galNoqOutCnhhomannj)),
SUM(DECODE(SIGN(galRlAddwtswestghC_00), -1,'',galRlAddwtswestghC_00)),
SUM(DECODE(SIGN(galRlAddwtswestghP_00), -1,'',galRlAddwtswestghP_00)),
SUM(DECODE(SIGN(galRlAddwtswestghP_01), -1,'',galRlAddwtswestghP_01)),
SUM(DECODE(SIGN(galRlAddwtswestgk_00), -1,'',galRlAddwtswestgk_00)),
SUM(DECODE(SIGN(galRlAddwtswestgk_01), -1,'',galRlAddwtswestgk_01)),
SUM(DECODE(SIGN(galRlAddwtswestgk_02), -1,'',galRlAddwtswestgk_02)),
SUM(DECODE(SIGN(galRlAddqwestghCs_00), -1,'',galRlAddqwestghCs_00)),
SUM(DECODE(SIGN(galRlAddqwestghPk_00), -1,'',galRlAddqwestghPk_00)),
SUM(DECODE(SIGN(galRlAddqwestghPk_01), -1,'',galRlAddqwestghPk_01)),
SUM(DECODE(SIGN(galRlAddqwestgkp_00), -1,'',galRlAddqwestgkp_00)),
SUM(DECODE(SIGN(galRlAddqwestgkt_00), -1,'',galRlAddqwestgkt_00)),
SUM(DECODE(SIGN(galRlAddqwestgkt_01), -1,'',galRlAddqwestgkt_01)),
SUM(DECODE(SIGN(galqNonloveIeFqHoCs_00), -1,'',galqNonloveIeFqHoCs_00)),
SUM(DECODE(SIGN(galqNonloveIeFqHoCs_01), -1,'',galqNonloveIeFqHoCs_01)),
SUM(DECODE(SIGN(galqNonloveIeFqHoPs_00), -1,'',galqNonloveIeFqHoPs_00)),
SUM(DECODE(SIGN(galqNonloveIeFqHoPs_01), -1,'',galqNonloveIeFqHoPs_01)),
SUM(DECODE(SIGN(galqNonloveIeFqHoSt_00), -1,'',galqNonloveIeFqHoSt_00)),
SUM(DECODE(SIGN(smleYaIfInOctetsHi), -1,'',smleYaIfInOctetsHi)),
SUM(DECODE(SIGN(smleYaIfInOctetsLo), -1,'',smleYaIfInOctetsLo)),
SUM(DECODE(SIGN(smleYaIfInUnknownProtos), -1,'',smleYaIfInUnknownProtos)),
SUM(DECODE(SIGN(smleYaIfOutOctetsHi), -1,'',smleYaIfOutOctetsHi)),
SUM(DECODE(SIGN(smleYaIfOutOctetsLo), -1,'',smleYaIfOutOctetsLo)),
SUM(DECODE(SIGN(greenew), -1,'',greenew)),
SUM(DECODE(SIGN(redAttk),-1,'',redAttk)),
SUM(DECODE(SIGN(mannjRetrnO_00), -1,'',mannjRetrnO_00)),
SUM(DECODE(SIGN(mannjRetrnO_01), -1,'',mannjRetrnO_01)),
SUM(DECODE(SIGN(mannjqessew),-1,'',mannjqessew)),
SUM(DECODE(SIGN(mannjqessk), -1,'',mannjqessk)),
SUM(DECODE(SIGN(foolYaNordSawYasgs), -1,'',foolYaNordSawYasgs)),
SUM(DECODE(SIGN(foolYaNohmmedTcpdee), -1,'',foolYaNohmmedTcpdee)),
SUM(DECODE(SIGN(foolYaNoSentSawYasgs), -1,'',foolYaNoSentSawYasgs)),
SUM(DECODE(SIGN(galAttNonctIfhoPsIntew),-1,'',galAttNonctIfhoPsIntew)),
SUM(DECODE(SIGN(galAttNonctIfhoPsIntk), -1,'',galAttNonctIfhoPsIntk)),
SUM(DECODE(SIGN(galAttNonctIfhoPsStrk), -1,'',galAttNonctIfhoPsStrk)),
SUM(DECODE(SIGN(galFlNonloveIfhoFlRe_00), -1,'',galFlNonloveIfhoFlRe_00)),
SUM(DECODE(SIGN(galFlNonloveIfhoFlRe_01), -1,'',galFlNonloveIfhoFlRe_01)),
SUM(DECODE(SIGN(galFlNonloveIfhoFlRe_02), -1,'',galFlNonloveIfhoFlRe_02)),
SUM(DECODE(SIGN(galFlNonloveIfhoRevPsI_00), -1,'',galFlNonloveIfhoRevPsI_00)),
SUM(DECODE(SIGN(galFlNonloveIfhoRevPsIntk),-1,'',galFlNonloveIfhoRevPsIntk)),
SUM(DECODE(SIGN(galFlNonloveIfhoRevPsStrk),-1,'',galFlNonloveIfhoRevPsStrk)),
SUM(DECODE(SIGN(galqNonloveIfhoPsIntew),-1,'',galqNonloveIfhoPsIntew)),
SUM(DECODE(SIGN(galqNonctIfhoPsIntk),-1,'',galqNonctIfhoPsIntk)),
SUM(DECODE(SIGN(galqNonctIfhoPsStrk),-1,'',galqNonctIfhoPsStrk)),
SUM(DECODE(SIGN(MyYapptRejHwaschd), -1,'',MyYapptRejHwaschd)),
SUM(DECODE(SIGN(MyYaCtypptAttaschd),-1,'',MyYaCtypptAttaschd)),
SUM(DECODE(SIGN(MyYaCtypptAttkPds_00), -1,'',MyYaCtypptAttkPds_00)),
SUM(DECODE(SIGN(MyYaCtypptRejaschd),-1,'',MyYaCtypptRejaschd)),
SUM(DECODE(SIGN(MyYaCtypptRejkPds_00), -1,'',MyYaCtypptRejkPds_00)),
SUM(DECODE(SIGN(MyYaslesCtyaschd), -1,'',MyYaslesCtyaschd)),
SUM(DECODE(SIGN(MyYasCtyfrndjk), -1,'',MyYasCtyfrndjk)),
SUM(DECODE(SIGN(MyYamischd),-1,'',MyYamischd)),
SUM(DECODE(SIGN(MyYamityfrndjk), -1,'',MyYamityfrndjk)),
SUM(DECODE(SIGN(ladyCtypptAttServqad),-1,'',ladyCtypptAttServqad)),
SUM(DECODE(SIGN(ladyCtypptRejServqad),-1,'',ladyCtypptRejServqad)),
SUM(DECODE(SIGN(ladyNoActv10msItvlewTti10),-1,'',ladyNoActv10msItvlewTti10)),
SUM(DECODE(SIGN(YaNo),-1,'',YaNo)),
SUM(DECODE(SIGN(ladyNo1), -1,'',ladyNo1)),
SUM(DECODE(SIGN(ladyNo2), -1,'',ladyNo2)),
SUM(DECODE(SIGN(ladys), -1,'',ladys)),
SUM(DECODE(SIGN(lady00), -1,'',lady00)),
SUM(DECODE(SIGN(lady01), -1,'',lady01)),
SUM(DECODE(SIGN(ladySUM),-1,'',ladySUM)),
SUM(DECODE(SIGN(ladySUM00), -1,'',ladySUM00)),
SUM(DECODE(SIGN(ladySUM01), -1,'',ladySUM01)),
SUM(DECODE(SIGN(ladySUM),-1,'',ladySUM)),
SUM(DECODE(SIGN(NoYaAttLwhomannj), -1,'',NoYaAttLwhomannj)),
SUM(DECODE(SIGN(HiYaFlLwho), -1,'',HiYaFlLwho)),
SUM(DECODE(SIGN(HiYaFlLwho5), -1,'',HiYaFlLwho5)),
SUM(DECODE(SIGN(HiYaFlLwho500), -1,'',HiYaFlLwho500)),
SUM(DECODE(SIGN(HiYaFlLwho5), -1,'',HiYaFlLwho5)),
SUM(DECODE(SIGN(NoYaqLwhomannj), -1,'',NoYaqLwhomannj)),
SUM(DECODE(SIGN(gal6), -1,'',gal6)),
SUM(DECODE(SIGN(gal55), -1,'',gal55)),
SUM(DECODE(SIGN(gal4), -1,'',gal4)),
SUM(DECODE(SIGN(gal3), -1,'',gal3)),
SUM(DECODE(SIGN(galN1),-1,'',galN1)),
SUM(DECODE(SIGN(gal2), -1,'',gal2)),
SUM(DECODE(SIGN(Tool),-1,'',Tool)),
SUM(DECODE(SIGN(MyYaslehj), -1,'',MyYaslehj)),
SUM(DECODE(SIGN(aruhgDl),-1,'',aruhgDl)),
SUM(DECODE(SIGN(aruhgUl),-1,'',aruhgUl)),
SUM(DECODE(SIGN(MyYamigtumPqytr00), -1,'',MyYamigtumPqytr00)),
SUM(DECODE(SIGN(MyYamigtumPqytr01), -1,'',MyYamigtumPqytr01)),
SUM(DECODE(SIGN(MyYamigtumPqytr02), -1,'',MyYamigtumPqytr02)),
SUM(DECODE(SIGN(MyYamigtumPqytr03), -1,'',MyYamigtumPqytr03)),
SUM(DECODE(SIGN(MyYamigtumPqytr04), -1,'',MyYamigtumPqytr04)),
SUM(DECODE(SIGN(MyYamigtumPqytr05), -1,'',MyYamigtumPqytr05)),
SUM(DECODE(SIGN(MyYamigtumPqytr06), -1,'',MyYamigtumPqytr06)),
SUM(DECODE(SIGN(MyYamigtumPqytr07), -1,'',MyYamigtumPqytr07)),
SUM(DECODE(SIGN(MyYamigtumPqytr08), -1,'',MyYamigtumPqytr08)),
SUM(DECODE(SIGN(MyYamigtumPqytr09), -1,'',MyYamigtumPqytr09)),
SUM(DECODE(SIGN(MyYamigtumPqytr10), -1,'',MyYamigtumPqytr10)),
SUM(DECODE(SIGN(MyYamigtumPqytr11), -1,'',MyYamigtumPqytr11)),
SUM(DECODE(SIGN(MyYamigtumPqytr12), -1,'',MyYamigtumPqytr12)),
SUM(DECODE(SIGN(MyYamigtumPqytr13), -1,'',MyYamigtumPqytr13)),
SUM(DECODE(SIGN(MyYamigtumPqytr14), -1,'',MyYamigtumPqytr14)),
SUM(DECODE(SIGN(MyYamigtumPqytr15), -1,'',MyYamigtumPqytr15)),
SUM(DECODE(SIGN(MyYamii), -1,'',MyYamii)),
SUM(DECODE(SIGN(MyYamis), -1,'',MyYamis)),
SUM(DECODE(SIGN(MyYamie00),-1,'',MyYamie00)),
SUM(DECODE(SIGN(MyYamie01),-1,'',MyYamie01)),
SUM(DECODE(SIGN(MyYamie02),-1,'',MyYamie02)),
SUM(DECODE(SIGN(MyYamie03),-1,'',MyYamie03)),
SUM(DECODE(SIGN(MyYamie04),-1,'',MyYamie04)),
SUM(DECODE(SIGN(MyYamie05),-1,'',MyYamie05)),
SUM(DECODE(SIGN(MyYamie06),-1,'',MyYamie06)),
SUM(DECODE(SIGN(MyYamie07),-1,'',MyYamie07)),
SUM(DECODE(SIGN(MyYamie08),-1,'',MyYamie08)),
SUM(DECODE(SIGN(MyYamie09),-1,'',MyYamie09)),
SUM(DECODE(SIGN(MyYamie10),-1,'',MyYamie10)),
SUM(DECODE(SIGN(MyYamie11),-1,'',MyYamie11)),
SUM(DECODE(SIGN(MyYamie12),-1,'',MyYamie12)),
SUM(DECODE(SIGN(MyYamie13),-1,'',MyYamie13)),
SUM(DECODE(SIGN(MyYamie14),-1,'',MyYamie14)),
SUM(DECODE(SIGN(MyYamie15),-1,'',MyYamie15)),
SUM(DECODE(SIGN(MyYamij), -1,'',MyYamij)),
SUM(DECODE(SIGN(sacsledghDljk), -1,'',sacsledghDljk)),
SUM(DECODE(SIGN(Salmon),-1,'',Salmon)),
SUM(DECODE(SIGN(Alloy),-1,'',Alloy)),
SUM(DECODE(SIGN(Lemon),-1,'',Lemon)),
SUM(DECODE(SIGN(Dolph),-1,'',Dolph)),
SUM(DECODE(SIGN(Halw),-1,'',Halw)),
SUM(DECODE(SIGN(Coc),-1,'',Coc)),
SUM(DECODE(SIGN(Nut),-1,'',Nut)),
SUM(DECODE(SIGN(Smily),-1,'',Smily)),
SUM(DECODE(SIGN(Cosm),-1,'',Cosm)),
SUM(DECODE(SIGN(Loly),-1,'',Loly)),
SUM(DECODE(SIGN(Gold),-1,'',Gold)),
SUM(DECODE(SIGN(Silvy), -1,'',Silvy)),
SUM(DECODE(SIGN(Honey), -1,'',Honey))
FROM Value
GROUP by MSD
Also i got the below point from a site:
ORA-01467: sort key too long
Cause: A DISTINCT, GROUP BY, ORDER BY, or SET operation requires a sort key longer than that supported by Oracle. Either too many columns or too many group functions were specified in the SELECT statement.
Action: Reduce the number of columns or group functions involved in the operation.
However i am able to run the same query on a different table with almost double the number of columns.
Can anyone please help me in figuring out the actual cause of this error and the solution.
Thanks in advance,
ArunWell, as I already mentioned, there is no way to fit GROUP BY columns and all non distinct data aggregates into a single Otacle block. So I suggest to replace GROUP BY with analytic functions. I tested it and it works. I can not fit whole statement, since forum message limit it 30000 characters, so I will remove some trailing select list expressions. They all follow same pattern anyway:
SELECT DISTINCT MSD,
1,
SUM(FLAG) OVER(PARTITION BY MSD),
DECODE(SUM(FLAGCOLOR) OVER(PARTITION BY MSD),0,0,1),
SUM(DECODE(SIGN(Tiefool), -1,to_number(null),Tiefool)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Tiegreen), -1,to_number(null),Tiegreen)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(TiesacTotaru), -1,to_number(null),TiesacTotaru)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Tiesaccfaru), -1,to_number(null),Tiesaccfaru)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Tiel), -1,to_number(null),Tiel)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Tiemannj), -1,to_number(null),Tiemannj)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNo57), -1,to_number(null),HiYaNo57)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoAttOIRHoLad), -1,to_number(null),HiYaNoAttOIRHoLad)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoAttOIRHomannj), -1,to_number(null),HiYaNoAttOIRHomannj)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoAttOIRHosmrlone), -1,to_number(null),HiYaNoAttOIRHosmrlone)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoAttOSwHomannj), -1,to_number(null),HiYaNoAttOSwHomannj)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHoCs57jFlr),-1,to_number(null),HiYaNoFlOIRHoCs57jFlr)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHoCs57Re_00), -1,to_number(null),HiYaNoFlOIRHoCs57Re_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHoCs57Re_01), -1,to_number(null),HiYaNoFlOIRHoCs57Re_01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHoCs57Ue_00), -1,to_number(null),HiYaNoFlOIRHoCs57Ue_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHoLadG_00), -1,to_number(null),HiYaNoFlOIRHoLadG_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHoLadR_00), -1,to_number(null),HiYaNoFlOIRHoLadR_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHoLadR_01), -1,to_number(null),HiYaNoFlOIRHoLadR_01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHoLadU_00), -1,to_number(null),HiYaNoFlOIRHoLadU_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHomannj_00), -1,to_number(null),HiYaNoFlOIRHomannj_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHomannj_01), -1,to_number(null),HiYaNoFlOIRHomannj_01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHomannj_02), -1,to_number(null),HiYaNoFlOIRHomannj_02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHomannj_03), -1,to_number(null),HiYaNoFlOIRHomannj_03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHosmr_00), -1,to_number(null),HiYaNoFlOIRHosmr_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHosmr_01), -1,to_number(null),HiYaNoFlOIRHosmr_01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHosmr_02), -1,to_number(null),HiYaNoFlOIRHosmr_02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOIRHosmr_03), -1,to_number(null),HiYaNoFlOIRHosmr_03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOSwHomannj_00), -1,to_number(null),HiYaNoFlOSwHomannj_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOSwHomannj_01), -1,to_number(null),HiYaNoFlOSwHomannj_01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOSwHomannj_02), -1,to_number(null),HiYaNoFlOSwHomannj_02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoFlOSwHomannj_03), -1,to_number(null),HiYaNoFlOSwHomannj_03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoOIRCckOldCh), -1,to_number(null),HiYaNoOIRCckOldCh)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoOIRCcq), -1,to_number(null),HiYaNoOIRCcq)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoOIRHocAl_00), -1,to_number(null),HiYaNoOIRHocAl_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoOIRHokOldC_00), -1,to_number(null),HiYaNoOIRHokOldC_00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoOIRHokOldC_01), -1,to_number(null),HiYaNoOIRHokOldC_01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoOIRHoq), -1,to_number(null),HiYaNoOIRHoq)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYatoyCs57), -1,to_number(null),HiYatoyCs57)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYatoyLad), -1,to_number(null),HiYatoyLad)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYatoymannj), -1,to_number(null),HiYatoymannj)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYatoysmrlone),-1,to_number(null),HiYatoysmrlone)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(HiYaNoplymannj), -1,to_number(null),HiYaNoplymannj)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(redAtt), -1,to_number(null),redAtt)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(NoYaNoOutIratHoAtt), -1,to_number(null),NoYaNoOutIratHoAtt)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(vavaYakcttntodef), -1,to_number(null),vavaYakcttntodef)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(vavaYakcttntoMan), -1,to_number(null),vavaYakcttntoMan)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(vavaYaNoddvac), -1,to_number(null),vavaYaNoddvac)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(vavaYaNordvac), -1,to_number(null),vavaYaNordvac)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(vavaYasalRlcTotPktThp), -1,to_number(null),vavaYasalRlcTotPktThp)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(vavaYasalRlccfPktThp),-1,to_number(null),vavaYasalRlccfPktThp)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(vavaYamilRlcTotPktThp), -1,to_number(null),vavaYamilRlcTotPktThp)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(vavaYamilRlccfPktThp), -1,to_number(null),vavaYamilRlccfPktThp)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr00),-1,to_number(null),MyYaNoauwcupytr00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr01),-1,to_number(null),MyYaNoauwcupytr01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr02),-1,to_number(null),MyYaNoauwcupytr02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr03),-1,to_number(null),MyYaNoauwcupytr03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr04),-1,to_number(null),MyYaNoauwcupytr04)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr05),-1,to_number(null),MyYaNoauwcupytr05)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr06),-1,to_number(null),MyYaNoauwcupytr06)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr07),-1,to_number(null),MyYaNoauwcupytr07)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr08),-1,to_number(null),MyYaNoauwcupytr08)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr09),-1,to_number(null),MyYaNoauwcupytr09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr10),-1,to_number(null),MyYaNoauwcupytr10)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr11),-1,to_number(null),MyYaNoauwcupytr11)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr12),-1,to_number(null),MyYaNoauwcupytr12)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr13),-1,to_number(null),MyYaNoauwcupytr13)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr14),-1,to_number(null),MyYaNoauwcupytr14)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoauwcupytr15),-1,to_number(null),MyYaNoauwcupytr15)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra00),-1,to_number(null),MyYaNoravmyfFra00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra01),-1,to_number(null),MyYaNoravmyfFra01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra02),-1,to_number(null),MyYaNoravmyfFra02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra03),-1,to_number(null),MyYaNoravmyfFra03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra04),-1,to_number(null),MyYaNoravmyfFra04)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra05),-1,to_number(null),MyYaNoravmyfFra05)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra06),-1,to_number(null),MyYaNoravmyfFra06)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra07),-1,to_number(null),MyYaNoravmyfFra07)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra08),-1,to_number(null),MyYaNoravmyfFra08)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra09),-1,to_number(null),MyYaNoravmyfFra09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra10),-1,to_number(null),MyYaNoravmyfFra10)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra11),-1,to_number(null),MyYaNoravmyfFra11)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra12),-1,to_number(null),MyYaNoravmyfFra12)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra13),-1,to_number(null),MyYaNoravmyfFra13)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra14),-1,to_number(null),MyYaNoravmyfFra14)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaNoravmyfFra15),-1,to_number(null),MyYaNoravmyfFra15)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr00), -1,to_number(null),MyYamigtumytr00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr01), -1,to_number(null),MyYamigtumytr01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr02), -1,to_number(null),MyYamigtumytr02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr03), -1,to_number(null),MyYamigtumytr03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr04), -1,to_number(null),MyYamigtumytr04)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr05), -1,to_number(null),MyYamigtumytr05)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr06), -1,to_number(null),MyYamigtumytr06)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr07), -1,to_number(null),MyYamigtumytr07)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr08), -1,to_number(null),MyYamigtumytr08)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr09), -1,to_number(null),MyYamigtumytr09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr10), -1,to_number(null),MyYamigtumytr10)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr11), -1,to_number(null),MyYamigtumytr11)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr12), -1,to_number(null),MyYamigtumytr12)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr13), -1,to_number(null),MyYamigtumytr13)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr14), -1,to_number(null),MyYamigtumytr14)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigtumytr15), -1,to_number(null),MyYamigtumytr15)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr00), -1,to_number(null),MyYaSUMlolytr00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr01), -1,to_number(null),MyYaSUMlolytr01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr02), -1,to_number(null),MyYaSUMlolytr02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr03), -1,to_number(null),MyYaSUMlolytr03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr04), -1,to_number(null),MyYaSUMlolytr04)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr05), -1,to_number(null),MyYaSUMlolytr05)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr06), -1,to_number(null),MyYaSUMlolytr06)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr07), -1,to_number(null),MyYaSUMlolytr07)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr08), -1,to_number(null),MyYaSUMlolytr08)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr09), -1,to_number(null),MyYaSUMlolytr09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr10), -1,to_number(null),MyYaSUMlolytr10)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr11), -1,to_number(null),MyYaSUMlolytr11)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr12), -1,to_number(null),MyYaSUMlolytr12)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr13), -1,to_number(null),MyYaSUMlolytr13)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr14), -1,to_number(null),MyYaSUMlolytr14)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMlolytr15), -1,to_number(null),MyYaSUMlolytr15)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr00), -1,to_number(null),MyYaSUMgrtytr00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr01), -1,to_number(null),MyYaSUMgrtytr01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr02), -1,to_number(null),MyYaSUMgrtytr02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr03), -1,to_number(null),MyYaSUMgrtytr03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr04), -1,to_number(null),MyYaSUMgrtytr04)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr05), -1,to_number(null),MyYaSUMgrtytr05)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr06), -1,to_number(null),MyYaSUMgrtytr06)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr07), -1,to_number(null),MyYaSUMgrtytr07)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr08), -1,to_number(null),MyYaSUMgrtytr08)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr09), -1,to_number(null),MyYaSUMgrtytr09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr10), -1,to_number(null),MyYaSUMgrtytr10)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr11), -1,to_number(null),MyYaSUMgrtytr11)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr12), -1,to_number(null),MyYaSUMgrtytr12)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr13), -1,to_number(null),MyYaSUMgrtytr13)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr14), -1,to_number(null),MyYaSUMgrtytr14)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMgrtytr15), -1,to_number(null),MyYaSUMgrtytr15)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw00),-1,to_number(null),MyYamigcfvw00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw01),-1,to_number(null),MyYamigcfvw01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw02),-1,to_number(null),MyYamigcfvw02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw03),-1,to_number(null),MyYamigcfvw03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw04),-1,to_number(null),MyYamigcfvw04)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw05),-1,to_number(null),MyYamigcfvw05)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw06),-1,to_number(null),MyYamigcfvw06)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw07),-1,to_number(null),MyYamigcfvw07)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw08),-1,to_number(null),MyYamigcfvw08)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw09),-1,to_number(null),MyYamigcfvw09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw10),-1,to_number(null),MyYamigcfvw10)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw11),-1,to_number(null),MyYamigcfvw11)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw12),-1,to_number(null),MyYamigcfvw12)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw13),-1,to_number(null),MyYamigcfvw13)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw14),-1,to_number(null),MyYamigcfvw14)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamigcfvw15),-1,to_number(null),MyYamigcfvw15)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr00), -1,to_number(null),MyYaSUMNoOfcfsytr00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr01), -1,to_number(null),MyYaSUMNoOfcfsytr01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr02), -1,to_number(null),MyYaSUMNoOfcfsytr02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr03), -1,to_number(null),MyYaSUMNoOfcfsytr03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr04), -1,to_number(null),MyYaSUMNoOfcfsytr04)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr05), -1,to_number(null),MyYaSUMNoOfcfsytr05)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr06), -1,to_number(null),MyYaSUMNoOfcfsytr06)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr07), -1,to_number(null),MyYaSUMNoOfcfsytr07)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr08), -1,to_number(null),MyYaSUMNoOfcfsytr08)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr09), -1,to_number(null),MyYaSUMNoOfcfsytr09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr10), -1,to_number(null),MyYaSUMNoOfcfsytr10)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr11), -1,to_number(null),MyYaSUMNoOfcfsytr11)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr12), -1,to_number(null),MyYaSUMNoOfcfsytr12)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr13), -1,to_number(null),MyYaSUMNoOfcfsytr13)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr14), -1,to_number(null),MyYaSUMNoOfcfsytr14)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYaSUMNoOfcfsytr15), -1,to_number(null),MyYaSUMNoOfcfsytr15)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum00),-1,to_number(null),MyYamiiitum00)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum01),-1,to_number(null),MyYamiiitum01)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum02),-1,to_number(null),MyYamiiitum02)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum03),-1,to_number(null),MyYamiiitum03)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum04),-1,to_number(null),MyYamiiitum04)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum05),-1,to_number(null),MyYamiiitum05)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum06),-1,to_number(null),MyYamiiitum06)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum07),-1,to_number(null),MyYamiiitum07)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum08),-1,to_number(null),MyYamiiitum08)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum09),-1,to_number(null),MyYamiiitum09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum10),-1,to_number(null),MyYamiiitum10)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum11),-1,to_number(null),MyYamiiitum11)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum12),-1,to_number(null),MyYamiiitum12)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum13),-1,to_number(null),MyYamiiitum13)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum14),-1,to_number(null),MyYamiiitum14)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(MyYamiiitum15),-1,to_number(null),MyYamiiitum15)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Cart),-1,to_number(null),Cart)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carg),-1,to_number(null),Carg)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carw), -1,to_number(null),Carw)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Cars), -1,to_number(null),Cars)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carx),-1,to_number(null),Carx)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Cara), -1,to_number(null),Cara)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carxs), -1,to_number(null),Carxs)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carq),-1,to_number(null),Carq)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carp),-1,to_number(null),Carp)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Cark),-1,to_number(null),Cark)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carg), -1,to_number(null),Carg)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carn), -1,to_number(null),Carn)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(CarYgh), -1,to_number(null),CarYgh)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carty), -1,to_number(null),Carty)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(Carzx), -1,to_number(null),Carzx)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(asdef), -1,to_number(null),asdef)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(toyYaIncup), -1,to_number(null),toyYaIncup)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(toyYaInLostcup), -1,to_number(null),toyYaInLostcup)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(toyYaInOutOfwcup),-1,to_number(null),toyYaInOutOfwcup)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(toyYaOutcup), -1,to_number(null),toyYaOutcup)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(manYaNoddSdulk128), -1,to_number(null),manYaNoddSdulk128)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(manYaNoddSdulk256), -1,to_number(null),manYaNoddSdulk256)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(manYaNoddSdulk64), -1,to_number(null),manYaNoddSdulk64)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaDlfd12PsStrMwm128),-1,to_number(null),fudYaDlfd12PsStrMwm128)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaDlfd12PsStrMwm256),-1,to_number(null),fudYaDlfd12PsStrMwm256)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaDlfd12PsStrMwms64),-1,to_number(null),fudYaDlfd12PsStrMwms64)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaMwmsghCongTo), -1,to_number(null),fudYaMwmsghCongTo)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaMwmscttntodef), -1,to_number(null),fudYaMwmscttntodef)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaMwmscttntoMan), -1,to_number(null),fudYaMwmscttntoMan)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaNoamMwms09),-1,to_number(null),fudYaNoamMwms09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaNoFldMwmsSesLackRnRe),-1,to_number(null),fudYaNoFldMwmsSesLackRnRe)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaNoFldMwmsSesLackTnRe),-1,to_number(null),fudYaNoFldMwmsSesLackTnRe)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaNoqessMwms09),-1,to_number(null),fudYaNoqessMwms09)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaNoqMwmsSesrr), -1,to_number(null),fudYaNoqMwmsSesrr)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaNoteMwmsSesStop), -1,to_number(null),fudYaNoteMwmsSesStop)) OVER(PARTITION BY MSD),
SUM(DECODE(SIGN(fudYaslesMwmslg), -1,to_number(null),fudYaslesMwmslg)) OVER(PARTITION BY MSD)
FROM Value
/SY. -
ORA-01467: Sort key too long error.
Dear All,
I have a complex query having lot of joins. It is working fine.
I just added few functions to it i.e. now few fields are calculated using functions.
Now it start giving error: ORA-01467: Sort key too long error.
What may be the problem?
Please help.
-SameerORA-01467 sort key too long
Cause: A DISTINCT, GROUP BY, ORDER BY, or SET operation requires a sort key longer than that supported by Oracle. Either too many columns or too many group functions were specified in the SELECT statement.
Action: Reduce the number of columns or group functions involved in the operation. -
PL/SQL Automatic Constraint Handler(Code)
For those interested...
I created the following database code that automatically does the constraint check/return error message for you.
You could even take this a step further and create your own message repository...
This guy even grabs/checks for foreign key violations:
First part of code builds/returns dictionary data constraints for table that you specify.
It then loads this data into object type.
This object type will be referenced later in the database trigger that you create for table where you want to validate constraints
return DbCons_documents_Array
as
dbdata DbCons_documents_Array := DbCons_documents_Array();
i NUMBER := 1;
begin
FOR cns_rec IN(select child.child_cons_name clchild_cons_name,
child.parent_cons_name clparent_cons_name,
child.child_columns clchild_columns,
parent.parent_cons_name pparent_cons_name,
parent.parent_tname pparent_tname,
child.child_tname clchild_tname,
CONCAT(CONCAT('"',replace(replace(parent.parent_columns,'"',''),'''','')),'"') pparent_columns,
child.parent_cons_type pparent_cons_type
--CONCAT(CONCAT('''',web_form_array(find_web_frm_val).db_col_value),'''');
FROM (
select a.table_name child_tname,
a.constraint_name child_cons_name,
NVL(b.r_constraint_name,a.constraint_name) parent_cons_name,
b.constraint_type parent_cons_type,
max(decode(position, 1, '"'||column_name||'"',NULL)) ||
max(decode(position, 2,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 3,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 4,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 5,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 6,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 7,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 8,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 9,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,10,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,11,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,12,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,13,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,14,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,15,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,16,', '||'"'||column_name||'"',NULL))
child_columns
from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type IN ( 'U', 'R' )
--and nvl(B.r_constraint_name,B.constraint_name) = A.constraint_name
-- and nvl(a.r_owner,a.owner) = b.owner
group by a.table_name, a.constraint_name, b.r_constraint_name,b.constraint_type ) child,
( select a.constraint_name parent_cons_name,
a.table_name parent_tname,
max(decode(position, 1, '"'||column_name||'"',NULL)) ||
max(decode(position, 2,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 3,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 4,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 5,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 6,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 7,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 8,', '||'"'||column_name||'"',NULL)) ||
max(decode(position, 9,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,10,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,11,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,12,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,13,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,14,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,15,', '||'"'||column_name||'"',NULL)) ||
max(decode(position,16,', '||'"'||column_name||'"',NULL))
parent_columns
from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type in ( 'P', 'U', 'R' )
group by a.table_name, a.constraint_name ) parent
where child.parent_cons_name = parent.parent_cons_name
and child.child_tname = upper('YOUR TABLE NAME HERE')
LOOP
dbdata.extend(i);
dbdata(i) := cdrl5.dbconstraint_documents_rec(cns_rec.pparent_cons_name,cns_rec.clchild_tname,cns_rec.pparent_tname,cns_rec.pparent_columns,cns_rec.pparent_cons_type);
--dbdata(i) := '';
-- dbdata(i) := dbconstraint_rec('test','test','test','test');
--v_sql :=
-- dbdata(i).constraint_name;
i := i+1;
END LOOP;
FOR d IN 1..dbdata.COUNT
LOOP
IF dbdata(d).constraint_name IS NULL
THEN
dbdata.delete(d);
END IF;
END LOOP;
-- dbdata.delete;
return dbdata;
END;
Second part is code that is in trigger of table you are inserting into. Note that you have to store the table name/column name(that make up the constraint)/actual form values into pl/sql table:
DECLARE
v_sql VARCHAR2(32000);
v_literal_value VARCHAR2(100);
v_error_relay VARCHAR2(4000);
v_db_values NUMBER := 1;
v_dup_count NUMBER;
nforeign_key EXCEPTION;
TYPE DupRecordType IS REF CURSOR;
dup_rec_cv DupRecordType;
dbdata DbCons_Documents_Array := DbCons_Documents_Array(cdrl5.dbconstraint_documents_rec(null,null,null,null,null));
TYPE tokenTableType is TABLE of varchar2(4000) -- table for Stringtoken
index by binary_integer;
tokenChar VARCHAR2(4000) := '," ';
tokens tokenTableType;
vCnt integer := 1;
myLine varchar2(4000) := null;
Line varchar2(4000) := null;
vPos integer := 1;
TYPE form_rec IS RECORD
table_name VARCHAR2(100),
db_column VARCHAR2(100),
db_col_value VARCHAR2(1000)
TYPE form_type IS TABLE OF form_rec
INDEX BY binary_integer;
web_form_array form_type;
BEGIN
dbdata.DELETE;
-- IF :new.DOC_ID IS NOT NULL
-- THEN
NOTE: Load the below table(with values specified) for each table constraint
web_form_array(v_db_values).table_name :=
'YOUR TABLE NAME';
web_form_array(v_db_values).db_column :=
'YOUR FIELD NAME';
web_form_array(v_db_values).db_col_value :=
:new.;
v_db_values := v_db_values +1;
FOR cns_rec IN(select *
from TABLE ( cast( documents_cons_dml() as DbCons_documents_Array ))
LOOP
line :=
cns_rec.constraint_where;
v_sql := 'SELECT count(*) FROM '||cns_rec.constraint_column;
IF INSTR(line,',',1,1) <= 0
THEN
FOR find_web_frm_val IN 1..web_form_array.COUNT
LOOP
IF cns_rec.table_name = web_form_array(find_web_frm_val).table_name
AND replace(line,'"','') = web_form_array(find_web_frm_val).db_column
THEN
v_literal_value :=
CONCAT(CONCAT('''',web_form_array(find_web_frm_val).db_col_value),'''');
v_sql := v_sql||' WHERE '||' '||web_form_array(find_web_frm_val).db_column||' = '||v_literal_value;
END IF;
END LOOP;
ELSE
while (vPos <= length(line))
loop
if (length(replace(tokenChar,substr(line, vPos, 1), '')) = length(tokenChar))
then
myLine := myLine || substr(line, vPos, 1);
elsif (myLine is not NULL) then
tokens(vCnt) := myLine;
FOR find_web_frm_val IN 1..v_db_values
LOOP
IF cns_rec.table_name = web_form_array(find_web_frm_val).table_name
AND MYLine = web_form_array(find_web_frm_val).db_column
THEN
v_literal_value :=
CONCAT(CONCAT('''',web_form_array(find_web_frm_val).db_col_value),'''');
END IF;
end loop;
IF vCnt = 1
THEN
v_sql := v_sql||' WHERE '||' '||myLine||' = '||v_literal_value;
ELSE
v_sql := v_sql||' AND '||' '||myLine||' = '||v_literal_value;
END IF;
myLine := null;
vCnt := vCnt + 1;
end if;
vPos := vPos + 1;
end loop;
if (myLine is not NULL) then
tokens(vCnt) := myLine;
end if;
vCnt := 1;
vPos := 1;
END IF;
OPEN dup_rec_cv FOR v_sql;
FETCH dup_rec_cv
INTO v_dup_count;
CLOSE dup_rec_cv;
IF cns_rec.column_position = 'R'
THEN
IF v_dup_count <= 0
THEN
v_error_relay :=
'The form field value for Database Column '||' '||line||' '||' that was entered does not exist';
RAISE nforeign_key;
END IF;
ELSIF cns_rec.column_position = 'U'
THEN
IF v_dup_count > 0
THEN
RAISE DUP_VAL_ON_INDEX;
END IF;
END IF;
-- commit_trans(v_dup_count);
-- INSERT INTO test
-- values(line||' '||INSTR(line,',',1,1));
-- VALUES(cns_rec.constraint_name||' '||cns_rec.table_name||' '||cns_rec.constraint_column||' '||cns_rec.constraint_where);
-- values(v_sql||' '||vPos||' '||length(line));
-- VALUES(web_form_array(i).table_name||' '||CONCAT(CONCAT('''',web_form_array(i).db_col_value),'''')||' '||i);
--commit;
-- i := i+1;
END LOOP;
EXCEPTION
WHEN DUP_VAL_ON_INDEX
THEN
raise_application_error(-20101, 'Attempted to update duplicate. Cannot update '||:new.);
WHEN nforeign_key
THEN raise_application_error(-20101, v_error_relay||' '||' YOUR MESSAGE HERE '||:new.);
END;Mark:
Ordinarily, I not really a critical guy, but that thing is such a mess that I have to comment. I won't mention the complete lack of bind variables (which leads to the shared pool and hard parsing concerns), but as posted it won't even compile. I had some time to kill, so.
For starters, the big query in your function gets:
ORA-01467: sort key too long
on my 9.2.0.6 instance with 16K blocksize, and on my 9.2.0.1 instance with an 8K blocksize. Interestingly, it does work on my 8.1.7.4 instance with 8K blocks. So, I had to limit it to 15 columns.
You give no function name at all. Based on the trigger code, I assume the function should be documents_cons_dml. I also added a paramter to pass the table name since one could conceivably have more than one table in an application.
I also took the liberty of fixing your extend problem. In your code, you extend the array by one in the first iteration through the loop, by two in the second and so on. Which is why you need the delete loop at the end.
There is no definition for the DbCons_documents_Array that the function returns, so I assumed something like:
SQL> CREATE TYPE dbconstraint_documents_rec AS OBJECT (
2 constraint_name VARCHAR2(30),
3 table_name VARCHAR2(30),
4 constraint_column VARCHAR2(30),
5 constraint_where VARCHAR2(4000),
6 column_position VARCHAR2(1) );
7 /
Type created.
SQL> CREATE TYPE DbCons_documents_Array AS
2 VARRAY(50) OF dbconstraint_documents_rec;
3 /
Type created.I used the names that you used in the trigger, although the names don't seem to match with the column contents, must be code re-use.
So, now the function looks like:
SQL> CREATE FUNCTION documents_cons_dml (p_table_name IN VARCHAR2)
2 RETURN DbCons_documents_Array AS
3
4 dbdata DbCons_documents_Array := DbCons_documents_Array();
5 i NUMBER := 1;
6 BEGIN
7 FOR cns_rec IN(SELECT child.child_cons_name clchild_cons_name,
8 child.parent_cons_name clparent_cons_name,
9 child.child_columns clchild_columns,
10 parent.parent_cons_name pparent_cons_name,
11 parent.parent_tname pparent_tname,
12 child.child_tname clchild_tname,
13 CONCAT(CONCAT('"',REPLACE(REPLACE(parent.parent_columns,'"',''),'''','')),'"') pparent_columns,
14 child.parent_cons_type pparent_cons_type
15 FROM (SELECT a.table_name child_tname,
16 a.constraint_name child_cons_name,
17 NVL(b.r_constraint_name,a.constraint_name) parent_cons_name,
18 b.constraint_type parent_cons_type,
19 MAX(DECODE(position, 1, '"'||column_name||'"',NULL)) ||
20 MAX(DECODE(position, 2,', "'||column_name||'"',NULL)) ||
21 MAX(DECODE(position, 3,', "'||column_name||'"',NULL)) ||
22 MAX(DECODE(position, 4,', "'||column_name||'"',NULL)) ||
23 MAX(DECODE(position, 5,', "'||column_name||'"',NULL)) ||
24 MAX(DECODE(position, 6,', "'||column_name||'"',NULL)) ||
25 MAX(DECODE(position, 7,', "'||column_name||'"',NULL)) ||
26 MAX(DECODE(position, 8,', "'||column_name||'"',NULL)) ||
27 MAX(DECODE(position, 9,', "'||column_name||'"',NULL)) ||
28 MAX(DECODE(position,10,', "'||column_name||'"',NULL)) ||
29 MAX(DECODE(position,11,', "'||column_name||'"',NULL)) ||
30 MAX(DECODE(position,12,', "'||column_name||'"',NULL)) ||
31 MAX(DECODE(position,13,', "'||column_name||'"',NULL)) ||
32 MAX(DECODE(position,14,', "'||column_name||'"',NULL)) ||
33 MAX(DECODE(position,15,', "'||column_name||'"',NULL)) child_columns
34 FROM user_cons_columns a, user_constraints b
35 WHERE a.constraint_name = b.constraint_name and
36 b.constraint_type IN ( 'U', 'R' )
37 GROUP BY a.table_name, a.constraint_name,
38 b.r_constraint_name,b.constraint_type ) child,
39 (SELECT a.constraint_name parent_cons_name,
40 a.table_name parent_tname,
41 MAX(DECODE(position, 1, '"'||column_name||'"',NULL)) ||
42 MAX(DECODE(position, 2,', "'||column_name||'"',NULL)) ||
43 MAX(DECODE(position, 3,', "'||column_name||'"',NULL)) ||
44 MAX(DECODE(position, 4,', "'||column_name||'"',NULL)) ||
45 MAX(DECODE(position, 5,', "'||column_name||'"',NULL)) ||
46 MAX(DECODE(position, 6,', "'||column_name||'"',NULL)) ||
47 MAX(DECODE(position, 7,', "'||column_name||'"',NULL)) ||
48 MAX(DECODE(position, 8,', "'||column_name||'"',NULL)) ||
49 MAX(DECODE(position, 9,', "'||column_name||'"',NULL)) ||
50 MAX(DECODE(position,10,', "'||column_name||'"',NULL)) ||
51 MAX(DECODE(position,11,', "'||column_name||'"',NULL)) ||
52 MAX(DECODE(position,12,', "'||column_name||'"',NULL)) ||
53 MAX(DECODE(position,13,', "'||column_name||'"',NULL)) ||
54 MAX(DECODE(position,14,', "'||column_name||'"',NULL)) ||
55 MAX(DECODE(position,15,', "'||column_name||'"',NULL)) parent_columns
56 FROM user_cons_columns a, user_constraints b
57 WHERE a.constraint_name = b.constraint_name and
58 b.constraint_type IN ( 'P', 'U', 'R' )
59 GROUP BY a.table_name, a.constraint_name ) parent
60 WHERE child.parent_cons_name = parent.parent_cons_name and
61 child.child_tname = upper(p_table_name)) LOOP
62 dbdata.extend;
63 dbdata(i) := dbconstraint_documents_rec(cns_rec.pparent_cons_name,
64 cns_rec.clchild_tname,
65 cns_rec.pparent_tname,
66 cns_rec.pparent_columns,
67 cns_rec.pparent_cons_type);
68 i := i+1;
69 END LOOP;
70 RETURN dbdata;
71 END;
72 /
Function created.
SQL> CREATE TABLE t (ID NUMBER PRIMARY KEY, descr VARCHAR2(10));
Table created.
SQL> CREATE TABLE t1 (idt1 NUMBER PRIMARY KEY, descr VARCHAR2(10));
Table created.
SQL> ALTER TABLE t ADD CONSTRAINT t_fk
2 FOREIGN KEY (id) REFERENCES t1 (idt1);
Table altered.Now for the trigger. Once I got rid of the schema owner cdrl5 in the dbconstraint_documents_rec call it actually compiled first time. So, my trigger looks like:
SQL> CREATE OR REPLACE TRIGGER t_bi
2 BEFORE INSERT ON t
3 FOR EACH ROW
4 DECLARE
5 v_sql VARCHAR2(32000);
6 v_literal_value VARCHAR2(100);
7 v_error_relay VARCHAR2(4000);
8 v_db_values NUMBER := 1;
9 v_dup_count NUMBER;
10 nforeign_key EXCEPTION;
11
12 TYPE DupRecordType IS REF CURSOR;
13 dup_rec_cv DupRecordType;
14
15 dbdata DbCons_Documents_Array := DbCons_Documents_Array(dbconstraint_documents_rec(null,null,null,null,null));
16
17 TYPE tokenTableType IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
18 tokenChar VARCHAR2(4000) := '," ';
19 tokens tokenTableType;
20 vCnt INTEGER := 1;
21 myLine VARCHAR2(4000) := NULL;
22 Line VARCHAR2(4000) := NULL;
23 vPos INTEGER := 1;
24
25 TYPE form_rec IS RECORD (
26 table_name VARCHAR2(100),
27 db_column VARCHAR2(100),
28 db_col_value VARCHAR2(1000));
29
30 TYPE form_type IS TABLE OF form_rec INDEX BY BINARY_INTEGER;
31 web_form_array form_type;
32
33 BEGIN
34 dbdata.DELETE;
35 -- NOTE: Load the below table(with values specified) for each table constraint
36
37 web_form_array(v_db_values).table_name := 'T';
38 web_form_array(v_db_values).db_column := 'ID';
39 web_form_array(v_db_values).db_col_value := :new.ID;
40 v_db_values := v_db_values +1;
41
42 FOR cns_rec IN(SELECT *
43 FROM TABLE ( CAST(documents_cons_dml('T') AS DbCons_documents_Array ))) LOOP
44 line := cns_rec.constraint_where;
45 v_sql := 'SELECT count(*) FROM '||cns_rec.constraint_column;
46 IF INSTR(line,',',1,1) <= 0 THEN
47 FOR find_web_frm_val IN 1 .. web_form_array.COUNT LOOP
48 IF cns_rec.table_name = web_form_array(find_web_frm_val).table_name AND
49 REPLACE(line,'"','') = web_form_array(find_web_frm_val).db_column THEN
50
51 v_literal_value :=CONCAT(CONCAT('''',web_form_array(find_web_frm_val).db_col_value),'''');
52 v_sql := v_sql||' WHERE '||' '||web_form_array(find_web_frm_val).db_column||' = '||v_literal_value;
53 END IF;
54 END LOOP;
55 ELSE
56 WHILE (vPos <= LENGTH(line)) LOOP
57 IF (LENGTH(REPLACE(tokenChar,substr(line, vPos, 1), '')) = LENGTH(tokenChar)) THEN
58 myLine := myLine || substr(line, vPos, 1);
59 ELSIF (myLine IS NOT NULL) THEN
60 tokens(vCnt) := myLine;
61 FOR find_web_frm_val IN 1 .. v_db_values LOOP
62 IF cns_rec.table_name = web_form_array(find_web_frm_val).table_name AND
63 MYLine = web_form_array(find_web_frm_val).db_column THEN
64 v_literal_value := CONCAT(CONCAT('''',web_form_array(find_web_frm_val).db_col_value),'''');
65 END IF;
66 END LOOP;
67 IF vCnt = 1 THEN
68 v_sql := v_sql||' WHERE '||' '||myLine||' = '||v_literal_value;
69 ELSE
70 v_sql := v_sql||' AND '||' '||myLine||' = '||v_literal_value;
71 END IF;
72 myLine := null;
73 vCnt := vCnt + 1;
74 END IF;
75 vPos := vPos + 1;
76 END LOOP;
77
78 IF (myLine IS NOT NULL) THEN
79 tokens(vCnt) := myLine;
80 END IF;
81 vCnt := 1;
82 vPos := 1;
83 END IF;
84
85 OPEN dup_rec_cv FOR v_sql;
86 FETCH dup_rec_cv INTO v_dup_count;
87 CLOSE dup_rec_cv;
88 IF cns_rec.column_position = 'R' THEN
89 IF v_dup_count <= 0 THEN
90 v_error_relay := 'The form field value for Database Column '||' '||line||' '||' that was entered does not exist';
91 RAISE nforeign_key;
92 END IF;
93 ELSIF cns_rec.column_position = 'U' THEN
94 IF v_dup_count > 0 THEN
95 RAISE DUP_VAL_ON_INDEX;
96 END IF;
97 END IF;
98 END LOOP;
99 EXCEPTION
100 WHEN DUP_VAL_ON_INDEX THEN
101 raise_application_error(-20101, 'Attempted to update duplicate. Cannot update '||:new.ID);
102 WHEN nforeign_key THEN
103 raise_application_error(-20101, v_error_relay||' '||' YOUR MESSAGE HERE '||:new.ID);
104 END;
105 /
Trigger created.So, lets try this puppy out.
SQL> INSERT INTO t1 VALUES (1, 'T1 ONE');
1 row created.
SQL> COMMIT;
Commit complete.I want at least one valid value to make sure I can actually insert something without dying on the trigger.
SQL> INSERT INTO t VALUES (1, 'T One');
1 row created.
SQL> COMMIT;
Commit complete.Which we can. Now lets test the Primary Key.
SQL> INSERT INTO t VALUES (1, 'T One');
INSERT INTO t VALUES (1, 'T One')
ERROR at line 1:
ORA-00001: unique constraint (OPS$ORACLE.SYS_C0027113) violatedOOPS, that's Oracle's message. Well, maybe it's because you are only checking cns_rec.column_position for R or U and my constraint is a P, and by the way, your function does not return the Primary Key for the table passed at all.
So, lets try the foreign key:
SQL> INSERT INTO t VALUES (2, 'T Two');
INSERT INTO t VALUES (2, 'T Two')
ERROR at line 1:
ORA-02291: integrity constraint (OPS$ORACLE.T_FK) violated - parent key not foundOOPS. So, for every valid insert I am doing a huge amount of extra work, and I still get Oracle's errors when it's wrong. If I have screwed something up in the set-up, please feel free to post a working example exactly as I did here.
John -
Maximum no. of columns allowed in SELECT clause - Urgent please
Hi,
I am constructing SQL query dynamically in a stored proc. based on user inputs. I am getting following error when I have around 400 columns in my SELECT clause. FROM, WHERE, GROUP BY clauses are same eventhough I have 30 columns and I don't have any problems here. Can anyone please let me know what is maximum no. of columns allowed in a query. I am working on Oracle 9i Release2.
Thanks in advance.ORA-01467 sort key too longIt's not the SELECT clause that causes this, it's most likely the GROUP BY clause. Basically, the columns in the GROUP BY clause have to fit comfortably within a single database block. Does that sound like it might be a problem with your query?
Cheers, APC
Message was edited by:
APC -
I am getting sort key error when I run the below error. what is the problem with this query
select a.table_name child_table,
a.constraint_name child_constraint,
max(decode(a.position, 1, a.column_name,NULL)) ||
max(decode(a.position, 2,', '||a.column_name,NULL)) ||
max(decode(a.position, 3,', '||a.column_name,NULL)) ||
max(decode(a.position, 4,', '||a.column_name,NULL)) ||
max(decode(a.position, 5,', '||a.column_name,NULL)) ||
max(decode(a.position, 6,', '||a.column_name,NULL)) ||
max(decode(a.position, 7,', '||a.column_name,NULL)) ||
max(decode(a.position, 8,', '||a.column_name,NULL)) ||
max(decode(a.position, 9,', '||a.column_name,NULL)) ||
max(decode(a.position,10,', '||a.column_name,NULL)) ||
max(decode(a.position,11,', '||a.column_name,NULL)) ||
max(decode(a.position,12,', '||a.column_name,NULL)) ||
max(decode(a.position,13,', '||a.column_name,NULL)) ||
max(decode(a.position,14,', '||a.column_name,NULL)) ||
max(decode(a.position,15,', '||a.column_name,NULL)) ||
max(decode(a.position,16,', '||a.column_name,NULL)) child_columns,
c.table_name as parent_table,
b.R_CONSTRAINT_NAME parent_constraint,
max(decode(d.position, 1, d.column_name,NULL)) ||
max(decode(d.position, 2,', '||d.column_name,NULL)) ||
max(decode(d.position, 3,', '||d.column_name,NULL)) ||
max(decode(d.position, 4,', '||d.column_name,NULL)) ||
max(decode(d.position, 5,', '||d.column_name,NULL)) ||
max(decode(d.position, 6,', '||d.column_name,NULL)) ||
max(decode(d.position, 7,', '||d.column_name,NULL)) ||
max(decode(d.position, 8,', '||d.column_name,NULL)) ||
max(decode(d.position, 9,', '||d.column_name,NULL)) ||
max(decode(d.position,10,', '||d.column_name,NULL)) ||
max(decode(d.position,11,', '||d.column_name,NULL)) ||
max(decode(d.position,12,', '||d.column_name,NULL)) ||
max(decode(d.position,13,', '||d.column_name,NULL)) ||
max(decode(d.position,14,', '||d.column_name,NULL)) ||
max(decode(d.position,15,', '||d.column_name,NULL)) ||
max(decode(d.position,16,', '||d.column_name,NULL)) parent_columns
from USER_cons_columns a, USER_constraints b , USER_constraints c, USER_cons_columns d
where a.constraint_name = b.constraint_name
and b.constraint_type = 'R'
and a.owner = b.owner
and a.owner = 'SCOTT'
and b.r_owner = c.owner
and b.R_CONSTRAINT_NAME = c.constraint_name
and c.constraint_name = d.constraint_name
and c.owner = d.owner
group by a.table_name, a.constraint_name,c.table_name,b.R_CONSTRAINT_NAME
order by child_table;
ERROR at line 37:
ORA-01467: sort key too longmake a short query and union to solve
select a.table_name child_table,
a.constraint_name child_constraint,
max(decode(a.position, 1, a.column_name,NULL)) ||
max(decode(a.position, 2,', '||a.column_name,NULL)) ||
max(decode(a.position, 3,', '||a.column_name,NULL)) ||
max(decode(a.position, 4,', '||a.column_name,NULL)) ||
max(decode(a.position, 5,', '||a.column_name,NULL)) ||
max(decode(a.position, 6,', '||a.column_name,NULL)) ||
max(decode(a.position, 7,', '||a.column_name,NULL)) ||
max(decode(a.position, 8,', '||a.column_name,NULL)) ||
max(decode(a.position, 9,', '||a.column_name,NULL)) ||
max(decode(a.position,10,', '||a.column_name,NULL)) ||
max(decode(a.position,11,', '||a.column_name,NULL)) ||
max(decode(a.position,12,', '||a.column_name,NULL)) ||
max(decode(a.position,13,', '||a.column_name,NULL)) ||
max(decode(a.position,14,', '||a.column_name,NULL)) ||
max(decode(a.position,15,', '||a.column_name,NULL)) ||
max(decode(a.position,16,', '||a.column_name,NULL)) child_columns
from USER_cons_columns a, USER_constraints b , USER_constraints c, USER_cons_columns d
where a.constraint_name = b.constraint_name
and b.constraint_type = 'R'
and a.owner = b.owner
and a.owner = 'SCOTT'
and b.r_owner = c.owner
and b.R_CONSTRAINT_NAME = c.constraint_name
and c.constraint_name = d.constraint_name
and c.owner = d.owner
group by a.table_name, a.constraint_name,c.table_name,b.R_CONSTRAINT_NAME
order by child_table -
Pivot table with very large number of columns
Hello,
here is the situation:
One table that contains raw data; from this table I feed one with extract information (3 fields); I have to turn the content in a pivot table
Ro --- Co --- Va
A A 1
A B 1
A C 2
B A 11
Turned in
A B C...
A 1 1 2
B 11 null null
To do this I do a query like:
select r, sum(decode(c,'A',Va) COLA, sum(decode(c,'B',Va) COLB , sum(decode(c,'C',Va) COLC,.... sum(decode(c,'XYZ',Va) COLXYZ from table group by r
The statement is generated by a script (cfmx) and it works until I reach a query that try to have 672 values for c; which means 672 columns...
Oracle doesn't like that: ORA-01467: sort key too long
I like this way has it is getting the result fast.
I have tried different solution a the CFMX level with for that specific query, I got timeout (query table with loop on co within loop on ro)
Is there any work around?
I am using Oracle 9i.
Tahnk you!insert into extracted_data select c, r, v, p from full_data where <specific_clause>
The values for C are from a query: select disctinct c from extracted_data
and it is the same for R
R and C are varchar2(3999)
I suppose that I can split on the first letter of the C column as:
SELECT r, low.cola, low.colb, . . ., low.colm,
high.coln, high.colo, . . ., high.colz
FROM (SELECT r, SUM(DECODE(c, 'A', va)) cola, . . .
SUM(DECODE(c, 'M', va)) colm
FROM table
WHERE c like 'A%'
GROUP BY r) Alpha_A,
(SELECT r, SUM(DECODE(c, 'N', va)) coln, . . .
SUM(DECODE(c, 'Z', va)) colz
FROM table
WHERE c like 'B%'
GROUP BY r) Alpha_B,
(SELECT r, SUM(DECODE(c, 'N', va)) coln, . . .
SUM(DECODE(c, 'Z', va)) colz
FROM table
WHERE c like 'C%'
GROUP BY r) Alpha_C
(SELECT r, SUM(DECODE(c, 'zN', va)) coln, . . .
SUM(DECODE(c, 'zZ', va)) colz
FROM table
WHERE c like 'Z%'
GROUP BY r) Alpha_Z
WHERE alpha_A.r = alpha_B.r and apha_a.r = alpha_C.r ... and alpha_a.r = alpha_z.r
I will have 27 select statement joined... I have to check if even like that I will not reach the limit within one of the statement select
"in real life"
select GRPW.r, GRPW.W0, GRPC.C0, GRPC.C1 from
(select r, sum(decode(C, 'Wall, unspecified',cases)) W0 from tmp_maqueje where upper(C) like 'W%' group by r) GRPW,
select r,
sum(decode(C, 'Ceramic tiles, indoors',cases)) C0,
sum(decode(C, 'Cement surface, outdoors (Concrete/cement block, see Structural element, A11)',cases)) C1
from tmp_maqueje where upper(C) like 'C%' group by r) GRPC
where GRPW.r = GRPC.r
order by GRPW.r, GRPW.W0, GRPC.C0, GRPC.C1
Message was edited by:
maquejp -
Hi Guys,
I have long query that will be loop depends on how many
years.
Select
<cfloop index="i" from="#min_year#" to="#max_year#"
step="1">
SUM(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wbs_budget_amt,NULL)) yr#i#,
SUM(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wba.Monte_Carlo_Min, NULL)) Monte_Carlo_Min#i#,
SUM(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wba.Monte_Carlo_Max, NULL)) Monte_Carlo_Max#i#,
SUM(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wba.Monte_Carlo_Likeliest, NULL)) Monte_Carlo_Likeliest#i#,
MAX(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
substr(wba.Comment_Text,1,100), NULL)) Comment_Text#i#,
MAX(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wba.Monte_Carlo_Distribution_Type, NULL))
MonteCarloDistribution#i#,
MAX(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wba.Discretionary_Spending_Status, NULL)) DiscretionarySpending#i#
SUM(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wba.MONTE_CARLO_MAX_PER, NULL)) Monte_Carlo_Max_Per#i#,
SUM(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wba.MONTE_CARLO_MIN_PER, NULL)) Monte_Carlo_Min_Per#i#,
SUM(DECODE(TO_CHAR(wbs_budget_date, 'YYYY'), #i#,
wba.MONTE_CARLO_LIKELIEST_PER, NULL)) Monte_Carlo_Likeliest_Per#i#
</cfloop>
From table name.
This query will return an error "[Macromedia][Oracle JDBC
Driver][Oracle]ORA-01467: sort key too long " if total year more
then 30 years. So do anyone have any idea how to prevent this error
happened?
Pls give me some ideas, really appriciate ideas fron all of
you guys.
Regards,
ShaffiqNormalize your database and you won't have problems like
this. -
'sort key too long error' while trying to use dynamic sql
Hi All,
I have been trying to generate an interactive report using a dynamically generated SQL query.. for this I have
1) Created a application process that returns the dynamically generated SELECT statement
2) Create a process in the page which creates a collection based on the SELECT statement returned by the application process
3) An interactive report that selects ALL (SELECT * ....) from that particular collection.
On implementing I am getting the 'ORA-01467: sort key too long' error.
On checking this out online I realized that one has to change the Block size of the database to get past this error, but in order to do that I would have to re-create the database, create a backup of the data and then re enter them into the new database which would be a nightmare.
I would like to know if there is any work around to this....
CODE IN THE APPLICATION PROCESS
DECLARE
q VARCHAR2(1000);
BEGIN
IF :P124_COUNTRY - :P124_WORK_GROUP - :P124_PRODUCT - :P124_ROLE = 1 THEN
q:= 'SELECT VISA_COUNTRY AS "Country", ROUND(((COUNT(VISA_ID)/(SELECT COUNT(ROW_ID) FROM PSA_RESOURCE_MANAGER WHERE ACTIVE_FLAG = ''Y''))*100),2) || ''%'' AS "Travel Readiness %" FROM PSA_VISA_INFO WHERE ACTIVE_FLAG = ''Y'' AND VISA_ACTIVE_FLAG = ''Y'' GROUP BY VISA_COUNTRY';
END IF;
return q;
END;
CODE IN THE PROCESS THAT CREATES THE COLLECTION:
APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY_B(
p_collection_name => 'TRAVRED_TEST',
p_query => 'application_process=set_query' );
CODE IN THE INTERACTIVE REPORT:
Select *
From apex_collections
Where collection_name = 'TRAVRED_TEST';
I also tried selecting just 'c001, c002' etc which gave me a 'no data found' output. The query work fine when I ran it in the SQL Workshop
Please help!
Thanks in advance :)Hey Ben,
I am getting the same error when I used the following code in the app process....
DECLARE
q VARCHAR2(32767);
BEGIN
IF :P124_COUNTRY - :P124_WORK_GROUP - :P124_PRODUCT - :P124_ROLE = 1 THEN
q:= 'SELECT visa_country,
COUNT(visa_id) visa_count
FROM psa_visa_info
WHERE active_flag = 'Y'
AND visa_active_flag = 'Y'
GROUP BY visa_country),
row_id_count AS
(SELECT /*+ MATERIALIZE */
COUNT(ROW_ID) row_count
FROM PSA_RESOURCE_MANAGER
WHERE ACTIVE_FLAG = 'Y')
SELECT visa_country,
ROUND(visa_count/(SELECT row_count FROM row_id_count)*100,2) travel_readiness FROM PSA_VISA_INFO WHERE ACTIVE_FLAG = ''Y'' AND VISA_ACTIVE_FLAG = ''Y'' GROUP BY VISA_COUNTRY';
END IF;
return q;
END;
Thanks -
Sort key too long error depends on values supplied to query
Please have a look at this query (Just given for guessing complications).
This query works and gives output for pro_id=1 and other few values.
But it fails for value 2.
SELECT *
FROM common_list_view_test
WHERE che_id != 14
AND(use_id = 299 OR iss_rec = 299 OR che_id IN
(SELECT a.m_che_id
FROM m_chk_pt a, m_role_chk_pt b, m_user c
WHERE a.m_che_id = b.m_che_id
AND b.m_rol_id = c.m_rol_id
AND c.m_use_id = 299))
AND pro_id = 2
ORDER BY iss_dat,
issue_stringFor pro_id = 2 it gives error:
ORA-01467: sort key too long
What do we mean by sort key?
Is it depends on supplied information and the records to be fetched.
If the query is going to fetch a lot of records then do this error occur?
How to avoid this error and make the query to work got pro_id=2.
-SameerIt is also not working for:
SELECT COUNT(*)
FROM common_list_view_test
WHERE pro_id = 2Please tell me what i have to do?
I can't rewrite common_list_view_test as i do not have enough priviledged to change its code, but this view is a lot complicated.
But then why it works for one value and not for another one?
Please help.
-Sameer -
PL/SQL report errors: ORA-01422
Hi all,
(before i you read i would like to say i have searched the net for this error code but nothing shows up like this problem..)
I am getting an error problem when i select certain Schemas from a list on an apex app. page, it only works for some schemas not all..
When i select one schema, it is supposed to display one row.. when i select [ALL] it is supposed to show them all.
It does work if i select '[ALL]' from the select list (p3_schema_name), just not for every single individual one.
the error code:
ORA-01422: exact fetch returns more than requested number of rows
declare
vSchema varchar2(20);
vStmt varchar2(1000);
vVersion number(5);
vDBName varchar2(20);
vHostName varchar2(80);
vStmt2 varchar2(1000);
vVersion2 number(5);
vDBName2 varchar2(20);
vServer2 varchar2(80);
vSchema2 varchar2(80);
CURSOR c_schemas IS
select owner from dba_tables@P3_DB_NAME.db_link where table_name = 'DDL_LOG' and num_rows > 0 order by owner;
begin
IF :P3_SCHEMA_NAME != '[ALL]' AND :P3_DB_NAME IS NOT NULL AND :P3_SERVER_NAME IS NOT NULL THEN
vServer2 := :P3_SERVER_NAME;
vSchema2 := :P3_SCHEMA_NAME;
vStmt2 := 'select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from &P3_SCHEMA_NAME..ddl_log@&P3_DB_NAME.db_link GROUP BY DDH_DB_NM';
Execute Immediate vStmt2 into vDBName2, vVersion2;
htp.p('<br>');
htp.p('<table border="1">');
htp.p('<tr>');
htp.p('<th bgcolor="#FFCC99">SERVER NAME</th>');
htp.p('<th bgcolor="#FFCC99">DB NAME</th>');
htp.p('<th bgcolor="#FFCC99">SCHEMA NAME</th>');
htp.p('<th bgcolor="#FFCC99">PATCH</th>');
htp.p('</tr>');
htp.p('<tr>');
htp.p('<td>');
htp.p(vServer2);
htp.p('</td>');
htp.p('<td>');
htp.p(vDBName2);
htp.p('</td>');
htp.p('<td>');
htp.p(vSchema2);
htp.p('</td>');
htp.p('<td>');
htp.p(vVersion2);
htp.p('</td>');
htp.p('<td>');
htp.p('<BR>');
htp.p('</td>');
htp.p('</tr>');
htp.p('</tr>');
htp.p('</table>');
ELSE IF :P3_SCHEMA_NAME = '[ALL]' AND :P3_DB_NAME IS NOT NULL AND :P3_SERVER_NAME IS NOT NULL THEN
vHostName := :P3_SERVER_NAME;
vDBName := :P3_DB_NAME;
open c_schemas;
htp.p('<br>');
htp.p('<table border="1">');
htp.p('<tr>');
htp.p('<th bgcolor="#FFCC99">SERVER NAME</th>');
htp.p('<th bgcolor="#FFCC99">DB NAME</th>');
htp.p('<th bgcolor="#FFCC99">SCHEMA NAME</th>');
htp.p('<th bgcolor="#FFCC99">PATCH</th>');
htp.p('</tr>');
LOOP
FETCH c_schemas INTO vSchema;
EXIT WHEN c_schemas%NOTFOUND;
vStmt := 'select max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from '||vSchema||'.ddl_log@&P3_DB_NAME.db_link where DDH_SCHEMA_NR = (select max(DDH_SCHEMA_NR) from '||vSchema||'.ddl_log@&P3_DB_NAME.db_link) and rownum < 2' ;
Execute Immediate vStmt into vVersion ;
htp.p('<tr>');
htp.p('<td>');
htp.p(vHostName);
htp.p('</td>');
htp.p('<td>');
htp.p(vDBName);
htp.p('</td>');
htp.p('<td>');
htp.p(vSchema);
htp.p('</td>');
htp.p('<td>');
htp.p(vVersion);
htp.p('</td>');
htp.p('<td>');
htp.p('<BR>');
htp.p('</td>');
htp.p('</tr>');
END LOOP;
htp.p('</tr>');
htp.p('</table>');
CLOSE c_schemas;
END IF;
END IF;
END;I have checked the DDH_SCHEMA_NR for repeating entries of the highest number.. some of the ones that dont work do have repeating entries some don't.
Sorry if this is confusing, i have tried to explain it as best as i can.
Thanks in advance for any help.
AshleighHello Ashleigh,
Based on your code, I'd start by running this piece of SQL via command-line (thru SQL Workshop, SQL*Plus, Toad, etc.), replacing &P3_SCHEMA_NAME. and &P3_DB_NAME. with values that are currently causing the routine to fail and see if it returns more than one row. I don't know your data, but DISTINCT and GROUP BY are typically used to return multiple (though grouped/summarized) rows. It appears to be the only statement that would cause the error your seeing (more than one row being returned into single variables).
select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from &P3_SCHEMA_NAME..ddl_log@&P3_DB_NAME.db_link GROUP BY DDH_DB_NM;I'm actually surprised that the code runs at all. I didn't think 'execute immediate' would know what to do with substitutions indicated as "&something." (I've typically seen that when substituting in dynamic HTML/Javascript code but maybe I'm learning something new). But since you already have vServer2 and vSchema2, I'd be more apt to code it as:
vStmt2 := 'select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from ' ||
vSchema2 || '.ddl_log@' || vServer2 || '.db_link GROUP BY DDH_DB_NM';Hope this helps,
John -
Ora-00604 error and ora 01000 error while report generation.
hi all,
I am trying to generate the multiple reports of same template through a program.
While this job is running, i get the following error at the BIP console and the reports don't get generated.
[101711_044115578][][EXCEPTION] java.sql.SQLException: ORA-00604: error occurred
at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
ORA-00604: error occurred at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded
Kindly help.
Thanks.Lots of resources with a simple search to see what this is about, for example:
http://www.orafaq.com/wiki/ORA-01000
ORA-01000: maximum open cursors exceeded
Cause: A host language program attempted to open too many cursors. The initialization parameter OPEN_CURSORS determines the maximum number of cursors per user.
Action: Modify the program to use fewer cursors. If this error occurs often, shut down Oracle, increase the value of OPEN_CURSORS, and then restart Oracle.
open_cursors parameter
http://download.oracle.com/docs/cd/E11882_01/server.112/e25513/initparams160.htm#REFRN10137
Oracle support note:
OERR: ORA-1000 maximum open cursors exceeded (Doc ID 18591.1) -
EA2: ORA-01427 clicking on a view in the navigator
SQLDev: 1.5.0.52.03
Java: 1.6.0_04
Oracle: 9.2.0.7.0
I'm getting the following error when I click on a view in the navigator pane:
An error was encountered performing the requested operation:
ORA-01427: single-row subquery returns more than one row 01427. 00000 - "single-row subquery returns more than one row"I'm not seeing any errors in the shell window.
After clicking on <OK> in the error dialog, the normal tabs (Columns, Data, Grants, Dependencies, Details, SQL) are displayed, but there is no content in the Columns tab.
All the other tabs seem to function normally.
Here is the DDL from the SQL tab
CREATE OR REPLACE VIEW "SUBSCRIPTIONS"
"ORDER_ID", "SUNBURST_ORDER_ID", "SIEBEL_ORDER_ID", "ACCOUNT_ID",
"COMP_ID", "SUBACCOUNT_ID", "START_DATE", "END_DATE", "PULL_DATE",
"SUBSCRIPTION_TYPE", "PRICE_CLASS", "DESCRIPTION", "SEAT_COUNT",
"ORDER_DURATION", "CALLBACK_INTERVAL", "UPDATE_DATE", "UPDATE_USERNAME",
"AFFILIATE"
AS
SELECT order_id,
sunburst_order_id,
siebel_order_id,
account_id,
comp_id,
subaccount_id,
start_date,
end_date,
pull_date,
product_id,
price_class,
product_name,
add_users,
order_duration,
callback_interval,
last_mdfy_date,
last_mdfy_emp,
affiliate
FROM csbcrossworlds.subscriptions;We have 15 views in this schema, 3 of them fail this way but the other 12 display the columns just fine. So far I am unable to detect any commonality.
Any ideas?Ok, I think I found the problem. The view in question (SUBSCRIPTIONS) is owned by 'PHILC' and it references a table named 'SUBSCRIPTIONS' owned by 'CSBCROSSWORLDS'. There are two other development schemas that also own tables named 'SUBSCRIPTIONS'.
I believe the 'Columns' tab is executing the query below. The subquery in this SQL tries to identify the primary key columns for the 'SUBSCRIPTIONS' view in my schema (PHILC):
SELECT
c.column_name,
DECODE(
data_type,
'CHAR', data_type||'('||c.data_length||')',
'VARCHAR', data_type||'('||c.data_length||')',
'VARCHAR2', data_type||'('||c.data_length||')',
'NCHAR' , data_type||'('||c.data_length||')',
'NUMBER' , DECODE(c.data_precision,null,'NUMBER', data_type||'('||c.data_precision||','||c.data_SCALE||')'),
'NVARCHAR', data_type||'('||c.data_length||')',
'NVARCHAR2', data_type||'('||c.data_length||')',
data_type) data_type,
DECODE(nullable, 'Y', 'Yes', 'No') nullable,
c.DATA_DEFAULT,
column_id,
com.comments,
(SELECT 1 FROM all_constraints, all_cons_columns
WHERE all_constraints.constraint_type = 'P' AND
all_constraints.constraint_name = all_cons_columns.constraint_name AND
all_constraints.owner = all_cons_columns.owner AND
all_cons_columns.table_name = c.table_name AND
c.column_name = all_cons_columns.column_name) Primary_Key,
c_update.insertable,
c_update.updatable,
c_update.deletable
FROM
sys.all_tab_Columns c, sys.all_col_comments com, sys.user_updatable_columns c_update
WHERE
c.owner = :OBJECT_OWNER AND
c.table_name = :OBJECT_NAME AND
c.table_name = com.table_name AND
c.owner = com.owner AND
c.column_name = com.column_name AND
c_update.column_name = com.column_name AND
c_update.table_name = com.table_name
;Extracting the subquery into this:
SELECT
all_constraints.owner,
all_constraints.table_name,
all_constraints.constraint_name
FROM all_constraints, all_cons_columns
WHERE
all_constraints.constraint_type = 'P' AND
all_constraints.constraint_name = all_cons_columns.constraint_name AND
all_constraints.owner = all_cons_columns.owner and
all_cons_columns.table_name = 'SUBSCRIPTIONS' and
'ORDER_ID' = all_cons_columns.column_name;I got this output:
owner table_name constraint_name
CUTOVER SUBSCRIPTIONS SUBSCRIPTIONS_PK
CROSSWORLDS SUBSCRIPTIONS SUBSCRIPTIONS_PK
CSBCROSSWORLDS SUBSCRIPTIONS SUBSCRIPTIONS_PKLooking at the DDL for the view, the row we really want is for owner 'CSBCROSSWORLDS'. Unfortunately, that means having to somehow parse the SQL text to extract the owner name...
Phil -
Using database-link in view to get around ORA-01031 error
I have been granted select rights on a users table. I am therefore able to select from his table. If however I try create a view against his table I run into the ORA-01031 problem. I have worked around this problem by creating a database-link to myself and then adding that to the view creation and it works. What are the downsides of using the database-link in this way?
The only down side I have been able to identify is that a extra session is created and that the CPU has a little extra work due to the LOOP BACK that takes place. I need to ensure the network is not unnessesarly used and therefore will need to ensure that 127.0.0.1 (local host) is used in the database connection discription. e.g.
create database link my_db_link connect to scott identified by tiger using '(description=(address=(protocol=tcp)(host=127.0.0.1) (Port = 1521) ) (connect_data= (sid=ora10g)))';
Maybe you are looking for
-
Not able to see hierarchial org structure by clicking on Expand this branch
Dear experts, I am currently using the Online data extraction via sap for Nakisa Integration with SAP Landscape. I have completed the configuration of Nakisa with the help of configuration guide and administrator guide - After completing administrato
-
Have been advised by my email provider (recently blocked account requiring password reset) that they will only reset the password after a proven anti virus and malware scan has been done on ipad and iphone. Is this necessary and if so what do i use
-
Why can I no longer undo in search bars?
Now that I'm using Mountain Lion, once I've pressed Enter in a search bar (e.g. in dictionary, firefox) I am no longer able to use Command+Z to undo my typing to get back to what was in the search bar before I pressed Enter. This means I can't go bac
-
Java Not Enabled WebEx Player cannot be installed or recording cannot be playback online because Java is disabled in your Web browser. Please enable Java and then try again. For instructions on enabling Java, see your browser's online Help.
-
Printing emails without headers and footers
I just purchased a new printer HP Deskjet 2510 series and use it with Microsoft XP. Have also used HP color lazer CP2025 and HP lazer P2055DN. I am trying to figure out how to print emails without the header and footer showing. I have been able to d