0

I have a huge sql query which causes problems:

select distinct subjectnr from proces where
(produkttypenr = 1 or produkttypenr = 3 or produkttypenr = 4 or produkttypenr = 5 or produkttypenr = 9 or produkttypenr = 17 or produkttypenr = 19 or produkttypenr = 20 or produkttypenr = 22 or produkttypenr = 23 or produkttypenr = 24 or produkttypenr = 25 or produkttypenr = 26 or produkttypenr = 27 or produkttypenr = 29 or produkttypenr = 30 or produkttypenr = 31 or produkttypenr = 32 or produkttypenr = 33)
and proces.gebruikernr = 97 and
(
procesid in (18920,25546,37815,34581,34580,25328,37821,37822,25949,28397,26304,26294,26300,26303,33103,25849,29520,25377,15099,37150,28874,20669,34596,34595,30375,37401,36597,31013,34695,33165,31050,25690,38102,32480,29451,29729,32043,31331,33297,37362,34283,37361,36781,30212,35755,22944,28518,19254,28681,31271,34857,34860,24257,24258,24263,30756,37445,37628,37629,33511,32440,37125,33501,35019,33502,32723,32916,24310,25800,25259,25801,25802,25097,25692,35363,35343,34722,34740,25711,34408,4820,28705,28707,28706,33032,36968,35461,19571,24404,25441,25969,25172,7095,6997,31980,31979,22957,25301,25049,23011,30389,31791,30358,25419,33672,32329,33682,32470,29196,23678,31265,33564,37861,38043,37885,31184,22829,22878,28473,28655,23804,25093,30053,32025,14268,4772,16286,29489,25964,34481,34483,31617,34482,34485,33879,32980,37579,26660,31759,11912,37819,24315,24304,24305,25364,24312,25523,24307,24313,24308,24319,24316,24335,36380,25658,38075,28272,26440,24796,37693,26070,38112,20375,31388,25248,25804,25807,25808,14503,24580,31464,31473,24302,3370,38034,29904,30092,27153,31417,31396,31825,37776,37774,32528,37366,26822,31736,29469,16172,27435,28564,31982,19425,25527,25528,24252,24253,32749,32862,25003,25002,29672,29671,29677,29676,19918,36541,37875,19109,36649,36710,19201,31650,30029,22001,20847,20848,34553,34552,34555,34554,34557,34556,34560,34559,34564,34563,23817,32713,32712,23812,26014,32715,37759,33657,37831,34308,23605,32553,37727,37760,24344,24345,34647,25266,32185,37810,24318,37832,24336,24330,24338,24339,36145,36496,24781,36904,36903,37127,21248,37481,29577,36195,36174,32133,24474,32617,19639,24970,28469,31771,32444,18896,23517,27151,37755,32974,35825,25757,25930,34240,34153,34503,34479,27492,27430,33492,29408,31268,25598,25087,24228,24223,24225,24229,16628,27348,27349,24226,33892,29927,29992,21016,14737,9078,22503,24700,26877,23486,34550,34561,37850,23755,31857,30264,30263,31350,38058,24413,33712,32690,37027,26281,37033,26084,34531,34530,34538,34537,34543,34542,37428,35043,24786,25428,25716,31711,34957,34956,30813,34959,34958,25101,34961,34960,24945,34963,34962,34965,34964,34968,24275,24276,24284,33961,27043,27050,25442,38025,25041,25694,24811,35341,38111,38042,35566,35568,36396,34147,32308,30030,34826,36416,35152,35594,37520,29329,34378,36156,25156,36744,35624,19256,34566,34565,34809,25510,33750,26271,33764,35779,37936,26672,23005,36200,26616,6553,4819,34967,34970,37670,26082,28400,37031,37847,36382,33814,33993,33994,33095,24456,24457,30143,35936,29989,26153,25891,2709,35702,26170,33158,35247,33498,33490,37234,32821,32806,36188,35831,19314,31899,23237,34222,33448,25078,33523,29097,31264,29096,37101,35571,35883,19815,33670,24199,36142,24196,24197,37249,37344,24200,35882,38231,33258,38216,24207,37870,26182,24222,38159,24216,24208,26181,24212,24217,24213,30648,32618,28636,8083,28699,31003,37767,30561,37768,37931,35042,35044,30771,35045,31735,30657,32202,30596,30597,35798,25336,30109,34116,30723,29025,24476,24477,28177,24481,24482,28152,34345,19625,30054,25783,35807,26174,36378,33880,34706,28116,36260,27713,34577,34576,34176,34177,23104,34579,32863,34881,19443,23810,23756,29337,34973,34407,34971,34972,28485,24244,24236,24241,24237,24242,24245,25258,35980,4793,27943,28185,34758,3103,20230,9255,36670,34925,37206,36056,2181,37928,34665,34664,19614,37778,19620,34935,34934,34937,31164,30159,34936,33989,36782,37608,27279,9512,34811,34645,34646,28011,35587,28667,33419,21154,37803,9926,24325,24328,24332,24333,31841,31562,31561,19374,19372,34134,34061,26456,24602,24541,24600,24542,34822,24311,24582,24170,24171,24351,24352,27717,27718,24267,23759,31348,24287,24285,24281,24282,24293,24294,24288,24290,24291,34284,25656,25267,6106,29878,29254,20961,31817,31810,31153,38103,28573,30072,34185,25152,23533,19776,24467,33205,35063,15098,25372,26473,26775,28775,24269,19531,24270,24272,19757,24273,25859,34562,26125,19817,24521,33470,27249,27250,23185,4463,17141,31737,35347,29417,35314,35254,32598,33635,33761,28292,31922,35960,29981,30448,29649,33314,34890,34884,31270,14799,23825,23826,24091,24093,26154,26168,26162,27016,25402,34608,34610,34609,34611,25331,26187,33647,33569,26410,20737,27790,28791,32991,36058,24902,25157,32441,37728,37845,37835,35834,37074,2569,34904,26335,26380,34701,24971,24968,27681,27788,28616,32536,32645,27791,23566,34909,9545,12975,35403,35402,35364,34145,35949,35132,35365,34126,32960,34159,35838,29549,37591,20222,21704,34243,7114,34374,11264,11116,34623,35038,34497,30905,32537,34264,31487,31488,35800,35547,14555,31806,32024,31807,31812,36483,37786,25779,36072,36867,34734,32962,25094,33318,5913,33148,35900,36030,36392,31896,29508,28012,28555,35133,34708,33147,29105,29128,38038,25046,35770,37585,36425,36560,36426,37587,37571,26556,26555,26547,25677,19963,23614,35581,24383,24382,19132,25088,25184,22897,28118,23653,13091,34344,35545,33587,25610,37844,30282,29121,34471,33234,29456,29466,37852,34307,27783,36875,35600,29486,31761,31990,32651,35932,35933,29516,34433,26546,34135,26599,21082,31569,32000,32090,32092,35041,17442,36692,36339,36201,31713,19049,33253,24538,29482,24539,31089,25207,30934,28484,33342,37385,37387,37386,37175,37388,28503,27912,33026,28467,32927,34926,34551,34649,34651,33760,32755,32753,33161,34713,32594,31343,30449,33333,36530,24086,34493,34911,36531,36795,36661,18894,19307,10246,19311,19305,37389,37390,37393,35966,37394,19914,34746,37395,28566,22906,36651,35393,32067,31777,34640,34281,34282,32338,32337,23006,35484,34470,34094,25673,34439,34437,34441,34868,35086,34870,34872,34874,34876,30011,34823,34865,30907,34259,33197,16658,31588,31591,31066,31590,31589,31630,24730,26069,31649,23828,20351,26064,25917,25721,37846,26833,25974,38223,38224,38225,38226,29854,34448,30906,30948,30947,28574,30877,25763,23319,34330,37424,37868,34451,32898,24266,34914,33364,27789,32854,27767,25540,27768,25471,30353,26210,23305,23033,27815,27814,27816,37869,28535,34852,31209,34516,28475,33604,13796,33562,30033,31551,37981,35881,31357,37904,34372,34512,34511,27559,9799,25649,4812,34922,34404) or 
procesid in (28009,34405,29798,30879,34569,34071,34205,34568,20546,29464,22631,24787,38031,38030,27608,37363,22853,38146,38143,33334,33548,37449,37757,37396,37397,37384,37398,25713,28447,24989,24324,24327,26693,34523,34522,34526,34525,32739,31824,33542,37462,37874,35203,35202,35892,23318,24264,29662,36836,36835,27021,38079,26434,18493,33128,33928,28599,32334,3255,29012,25350,34101,19238,30569,35893,38021,37287,36153,36154,34358,35832,36650,36683,31474,34529,34528,34533,34532,36765,19044,34217,34218,34394,31061,34644,35649,34648,33257,25853,33979,34368,34369,16670,16669,33491,33478,34705,33515,23853,29475,29474,26990,30388,19286,25096,27097,31416,34253,32535,23898,37884,36497,36323,37906,37695,38107,34496,33154,33640,37259,36091,36956,29112,36319,36197,25760,33866,36305,32297,23423,20722,28704,24697,24698,27905,32808,29473,31140,21750,37963,38155,24752,31114,25548,34201,5570,16657,3712,17035,19441,29148,33974,34263,34450,29423,30675,30676,26037,31577,37425,37431,26062,38020,37442,10673,23893,4051,28282,27558,25863,23892,36914,29803,29804,35248,27089,27630,38097,22236,21763,22313,24354,31002,22258,19025,20593,37376,30382,37988,33643,35092,33252,35093,35950,36010,35894,28824,29122,25394,34187,33631,26972,25037,24942,24349,33058,25246,31734,31465,33196,33232,23543,24937,35231,32427,29833,23454,23453,25358,34421,25013,21554,24364,25014,34422,34428,34429,24368,32983,37816,26248,37643,26249,33692,27733,26550,26549,20607,23805,29061,30446,37151,11630,36959,3003,22908,37697,37696,26881,28005,37444,37638,24953,37637,36307,34179,32552,21857,2457,2460,34813,33842,25717,19904,24369,25620,26635,2736,26087,12529,30022,25265,23836,23837,14798,32742,26266,36681,31059,34319,30467,29507,26065,19051,27532,29450,3507,23259,34788,36345,24926,8948,28624,34635,36300,34912,37527,36092,34425,36331,35795,36695,36644,31540,28687,37438,37439,28746,28053,28556,28546,26198,29506,25423,31344,31345,28529,27880,37202,37613,36798,26396,28613,36799,28612,36962,35486,5650,5645,3001,3491,9167,20771,37455,37653,37597,7117,21917,36598,21916,33957,37177,29511,35872,37359,33410,3521,27909,3737,24052,34744,34743,28173,28193,29255,38036,38039,38040,26737,28614,36278,37616,37614,28615,26566,27906,30755,34978,28960,32223,32224,27007,37297,37294,35899,38214,35500,37042,37818,37392,6061,35939,34887,34886,28637,37479,26747,32642,32668,37472,26946,37475,37477,28568,28567,28570,37470,28569,28571,29015,26495,28350,25904,29014,37488,38151,36350,11261,2679,38150,35367,38153,38144,37283,36682,36686,35560,3555,36703,38027,38028,36704,36582,38015,38016,36794,36800,36801,36335,35392,37834,35084,35827,35026,28823,12450,29278,28638,35776,32170,35988,32325,33162,33937,5778,5780,4560,35614,35613,28641,28642,28646,30273,28015,27072,32222,36354,35823,27052,37823,33733,30548,27383,29084,36929,37075,37211,37662,36070,37099,37242,37243,37598,37619,37528,37529,35082,38175,37003,38177,38182,34573,36218,34480,37580,37700,37626,37210,15909,34484,38222,28645,28647,28648,28650,28653,35979,36869,28654,28656,28657,28658,27680,29519,28044,29744,28135,27799,30823,33332,17334,37784,36042,26624,26862,32783,28076,29663,26838,27323,37853,37911,29736,34078,26716,37718,38173,38217,3532,6733,30788,30787,7058,37849,37802,37793,37777,36034,33679,37702,35058,35811,35062,34988,37781,37994,15908,23786,34286,34285,37901,35861,38004,38013,36936,28804,29504,4723,28660,28659,28662,28661,28663,28664,28665,28666,28668,28669,28670,28671,28672,28673,28674,28675,28676,28682,28683,28684,28649,30113,36862,35189,28789,29143,30115,34642,34643,33759,31892,34023,30167,32473,37228,37000,37096,36006,34856,34859,34863,34866,4303,4299,35069,36385,35989,35323,2584,6675,36009,20794,37154,36144,37244,36085,35599,35598,37185,38052,38054,35409,38056,38029,36987,37102,30111,27683,29892,28536,28541,28540,28542,31259,32714,28543,28544,28545,28549,28548,28551,28552,28607,28606,27979,31433,34212,31434,35821,36371,36370,38089,28913,3202,33891,27400,27079,3187,36573,37500,35233,36971,36572,35542,35673,38065,14520,14521,30936,34700,6941,34983,35731,36937,37346,35016,36989,35479,36876,36877,4126,4125,20244,29909,34280,34278,37503,37496,37494,37497,30532,34288,37263,31959,35926,2911,28959,28958,38245,29174,29571,29897,37572,38072,36580,37078,34092,26756,28366,31196,37919,14863,37773,34637,37952,36938,37577,38235,38236,5022,35879,37222,37223,3644,2251,37541,37542,29173,28425,29413,29412,28770,28769,28896,29713,30208,32640,32639,29944,7052,31000,34182,34033,33871,37070,36576,37725,37724,36961,6190,37891,37841,38008,38009,38010,37553,37482,30413,36694,36861,32846,35307,33878,36267,36809,37240,28600,28610,27289,34415,28822,28577,27806,28617,32787,28611,30350,28578,34021,28620,28619,28622,28621,28625,28627,37791,38081,35362,35870,35361,35330,34351,34349,34076,33533,33531,5117,5123,13843,5119,5980,37851,11077,32976,32979,23846,2500,2504,38202,35215,33808,35405,37825,32429,32428,20930,28626,36602,28628,28629,28630,28631,28632,28633,33340,32139,34456,29494,28168,3735,34736,34718,20657,37351,37620,37354,35191,37008,37349,35220,35221,36439,38201,37138,38116,38118,38129,38137,38139,36421,36444,36026,37538,35866,3705,37957,37047,35978,36102,38232,38248,36972,35981,36976,36100,37114,35991,37048,37122,37181,37183,37182,35085,36073,37956,35929,38104,24676,31404,36253,31454,31069,38050,16954,38045,16953,38048,38053,38044,33876,34478,37940,37939,33584,37942,37941,37164,37163,37765,35982,37257,37256,35833,35188,35187,37837,35522,37935,37907,36886,35366,35857,13114,3741,38114,38117,35732,8536,37262,2696,37686,37752,37828,37830,37829,37890,37892,37898,37085,6060,37930,26751,29515,29918,27810,33204,37356,36148,8667,37518,36466,37554,36468,4464,6327,6333,36864,34277,35889,36191,35790,35397,34279,6935,7050,37658,42311,36510,37036,37286,22817,36308,38172,37160,37741,38178,37764,37780,35237,38179,38183,38184,31027,31026,26953,26954,37921,38078,38082,28731,28912,30873,26483,26484,26831,31221,28865,28864,34474,34854,33527,37414,37501,35916,36870,37507,37502,37508,37513,37512,37517,37516) or 
procesid in (37785,37621,38158,37769,38109,37771,37232,5435,35356,36110,6700,37742,34641,36351,2881,29142,38094,29701,34908,34907,38096,38091,34515,34910,34913,34918,34916,27801,34915,34917,34921,34920,36193,38099,31472,30560,29355,27148,26559,27362,27318,26677,13090,26617,27023,26879,26878,28559,32153,32669,35953,36677,35124,34867,35078,34864,34871,34873,34875,34869,34877,35079,35070,34919,35049,34087,37022,37427,37082,36045,37916,36227,37072,38077,28039,35728,37652,36109,35796,2869,20022,11104,20023,34810,30713,48160,48161,48173,48167,48162,48179,48164,48168,48165,48174,48171,48193,48172,48180,48177,48183,48178,48187,48184,48199,48186,48194,48189,48205,48190,48200,48195,48211,48196,48206,48201,48216,48202,48212,48207,48221,48208,48217,48213,48227,48214,48222,48219,48233,48220,48228,48225,48249,48226,48234,48231,48241,48232,48327,48237,48242,48238,48250,48245,48255,48246,48261,48256,48267,48262,48277,48268,48283,48271,48278,48272,48289,48284,48299,48287,48305,48293,48300,48294,48311,48306,48318,48312,48335,48315,48328,48322,48355,48324,48336,48331,48341,48332,48347,48343,48363,48348,48356,48351,48371,48352,48364,48359,48379,48360,48372,48367,48386,48368,48380,48375,48401,48376,48387,48383,48389,48384,48393,48390,48407,48394,48402,48397,48423,48398,48408,48405,48411,48406,48419,48412,48433,48415,48424,48416,48439,48420,48428,48427,48434,48429,48447,48430,48440,48437,48438,48443,48444,43743,43739,43751,43740,43759,43744,43752,43747,43761,43748,43760,43755,43771,43756,43779,43764,43772,43767,43787,43768,43780,43775,43795,43776,43788,43783,43803,43784,43796,43791,43811,43792,43804,43799,43819,43800,43812,43807,43827,43808,43820,43815,43837,43816,43828,43823,43841,43824,43832,43830,43838,43833,43849,43834,43871,43842,43850,43845,43853,43846,43857,43855,43862,43859,43887,43864,43872,43867,43875,43868,43881,43876,43895,43882,43888,43885,43903,43886,43896,43891,43908,43892,43904,43899,43923,43900,43910,43905,43911,43906,43915,43912,43937,43916,43924,43919,43929,43920,43926,43925,43951,43930,43938,43933,43943,43934,43954,43939,43944,43940,43952,43947,43965,43948,43957,43953,43971,43958,43966,43961,43974,43962,43972,43967,43981,43968,43975,43982,43977,43991,43978,43986,43985,43987,43988,36889,35835,34976,35454,37900,37992,36088,37681,4790,30163,37537,48449,48448,48456,48450,48465,48457,48453,48459,48454,48472,48460,48466,48463,48478,48464,48473,48469,48485,48470,48479,48475,48481,48476,48489,48484,48499,48488,48507,48492,48500,48495,48517,48496,48508,48503,48513,48504,48603,48514,48524,48520,48535,48523,48542,48529,48536,48530,48551,48539,48556,48545,48552,48546,48561,48555,48567,48562,48573,48568,48579,48574,48584,48580,48589,48583,48595,48590,48627,48596,48604,48599,48609,48600,48619,48610,48643,48613,48620,48614,48628,48623,48633,48624,48709,48634,48645,48638,48655,48640,48661,48649,48656,48650,48671,48662,48677,48665,48672,48666,48683,48678,48689,48684,48695,48690,48701,48696,48717,48702,48710,48705,48729,48706,48718,48713,48721,48714,48733,48724,48730,48725,48741,48726,48747,48734,48742,48737,48755,48738,48748,48745,48763,48746,48756,48751,48771,48752,48764,48759,48760,48772,48767,48768,48775,48776,44011,43992,43995,43999,43996,44003,44000,44019,44004,44012,44007,44027,44008,44020,44015,44035,44016,44028,44023,44073,44024,44036,44031,44041,44032,44049,44042,44055,44045,44050,44046,44065,44056,44115,44059,44066,44060,44074,44069,44077,44070,44089,44080,44099,44083,44090,44084,44105,44093,44100,44094,44111,44103,44120,44109,44129,44118,44126,44122,44137,44124,44145,44130,44138,44133,44152,44134,44146,44141,44161,44142,44150,44148,44169,44154,44162,44157,44177,44158,44170,44165,44185,44166,44178,44173,44193,44174,44186,44181,44201,44182,44194,44189,44209,44190,44202,44197,44217,44198,44210,44205,44231,44206,44218,44213,44222,44214,44239,44224,44232,44227,44228,44240,44235,44245,44236,44254,44246,44265,44249,44256,44250,44271,44259,44266,44260,44276,44272,44281,44275,44287,44282,44297,44288,44307,44291,44298,44292,44301,44308,44302,44311,35396,36199,36160,36755,36181,37113,36640,36192,37116,36251,37897,35025,38148,36279,38106,34889,36063,36254,37720,37352,37217,37167,2509,37218,37805,37804,37493,3525,42240,29323,48787,48779,48805,48780,48788,48783,48797,48784,48813,48791,48798,48792,48806,48801,48821,48802,48814,48809,48847,48810,48822,48817,48831,48818,48835,48825,48832,48826,48839,48836,48855,48840,48848,48843,48863,48844,48856,48851,48871,48852,48864,48859,48879,48860,48872,48867,48887,48868,48880,48875,48901,48876,48888,48883,48893,48884,48909,48894,48902,48897,48929,48898,48910,48905,48921,48906,48917,48913,48936,48914,48922,48918,48930,48925,48947,48926,48938,48933,48955,48934,48943,48939,48948,48940,48963,48944,48956,48951,48969,48952,48964,48959,48981,48960,48970,48967,48973,48968,48995,48974,48982,48977,48987,48978,49005,48983,48988,48984,48996,48991,49001,48992,49010,48997,49002,48998,49006,49011,49007,49013,49008,49014,49017,44319,44312,44313,44331,44314,44321,44317,44323,44318,44337,44324,44332,44327,44343,44328,44338,44333,44365,44334,44344,44341,44347,44342,44358,44348,44383,44351,44361,44352,44355,44366,44362,44375,44430,44369,44376,44370,44384,44379,44389,44380,44397,44390,44409,44393,44400,44394,44415,44403,44410,44404,44425,44416,44457,44419,44426,44420,44437,44429,44443,44438,44449,44444,44469,44450,44458,44453,44466,44454,44478,44461,44468,44462,44476,44472,44485,44474,44493,44480,44486,44481,44501,44482,44494,44489,44509,44490,44502,44497,44517,44498,44510,44505,44525,44506,44518,44513,44533,44514,44526,44521,44541,44522,44534,44529,44549,44530,44542,44537,44557,44538,44550,44545,44565,44546,44558,44553,44573,44554,44566,44561,44581,44562,44574,44569,44589,44570,44582,44577,44609,44578,44590,44585,44597,44586,44605,44593,44598,44594,44617,44601,44610,44602,44606,44618,44613,44614,44621,34287,38160,34888,38055,37068,37067,34639,35865,4321,6150,11610,17371,37933,49027,49018,49019,49035,49020,49028,49023,49043,49024,49036,49031,49049,49032,49044,49039,49067,49040,49050,49045,49057) or 
procesid in (49046,49054,49052,49059,49055,49070,49060,49068,49063,49080,49064,49073,49069,49091,49074,49082,49077,49083,49078,49095,49084,49092,49087,49101,49088,49113,49096,49102,49097,49107,49098,49122,49103,49108,49104,49114,49111,49117,49112,49131,49118,49133,49124,49132,49127,49139,49128,49147,49136,49155,49140,49148,49143,49163,49144,49156,49151,49177,49152,49164,49159,49172,49160,49181,49167,49174,49168,49189,49178,49197,49182,49190,49185,49205,49186,49198,49193,49219,49194,49206,49201,49211,49202,49251,49212,49220,49215,49225,49216,49231,49226,49241,49229,49256,49235,49242,49236,49252,49247,49315,49248,49262,49255,49270,49264,49279,49267,49289,49273,49280,49274,49296,49283,49290,49284,49307,49293,49323,49301,49308,49302,49316,49311,49312,49324,49319,49320,49327,44643,44622,44625,44634,44626,44651,44629,44636,44630,44644,44639,44659,44640,44652,44647,44662,44648,44660,44655,44669,44656,44677,44664,44670,44665,44681,44666,44678,44673,44684,44674,44719,44682,44693,44686,44697,44689,44694,44690,44701,44698,44705,44702,44710,44708,44727,44712,44720,44715,44735,44716,44728,44723,44743,44724,44736,44731,44751,44732,44744,44739,44761,44740,44752,44747,44769,44748,44756,44754,44762,44757,44777,44758,44770,44765,44785,44766,44778,44773,44793,44774,44786,44781,44801,44782,44794,44789,44809,44790,44802,44797,44817,44798,44810,44805,44825,44806,44818,44813,44833,44814,44826,44821,44841,44822,44834,44829,44849,44830,44842,44837,44857,44838,44850,44845,44865,44846,44858,44853,44873,44854,44866,44861,44881,44862,44874,44869,44889,44870,44882,44877,44897,44878,44890,44885,44886,44898,44893,44907,44894,44903,44901,44912,44908,44919,44910,44915,44916,38003,38007,2242,37348,37347,21402,4105,34638,6995,34855,35452,5979,37136,37551,35789,36395,49348,49328,49331,49335,49332,49343,49336,49357,49339,49345,49340,49373,49350,49358,49353,49361,49354,49365,49363,49381,49366,49374,49369,49389,49370,49382,49377,49395,49378,49390,49385,49403,49386,49396,49391,49411,49392,49404,49399,49439,49400,49412,49407,49419,49408,49427,49415,49422,49416,49431,49425,49449,49432,49440,49435,49457,49436,49450,49445,49465,49446,49458,49453,49473,49454,49466,49461,49481,49462,49474,49469,49489,49470,49482,49477,49509,49478,49490,49485,49505,49486,49496,49493,49527,49499,49510,49500,49517,49506,49550,49513,49520,49514,49529,49523,49539,49524,49545,49533,49540,49534,49573,49546,49563,49552,49583,49557,49564,49558,49574,49569,49579,49570,49593,49580,49601,49586,49594,49589,49615,49590,49602,49597,49607,49598,49606,49604,49621,49608,49616,49611,49625,49612,49622,49617,49633,49618,49627,49624,49641,49628,49634,49631,49632,49642,49637,49638,49643,44941,44921,44929,44925,44933,44926,44930,44949,44934,44942,44937,44957,44938,44950,44945,44965,44946,44958,44953,44973,44954,44966,44961,44981,44962,44974,44969,44989,44970,44982,44977,44997,44978,44990,44985,45005,44986,44998,44993,45013,44994,45006,45001,45021,45002,45014,45009,45029,45010,45022,45017,45036,45018,45030,45025,45043,45026,45038,45033,45051,45034,45044,45039,45059,45040,45052,45047,45110,45048,45060,45055,45069,45056,45073,45063,45070,45064,45077,45074,45083,45079,45087,45084,45091,45088,45095,45092,45099,45096,45103,45101,45117,45104,45112,45107,45125,45108,45118,45113,45133,45114,45126,45121,45141,45122,45134,45129,45149,45130,45142,45137,45161,45138,45150,45145,45153,45146,45169,45154,45162,45157,45177,45158,45170,45165,45183,45166,45178,45173,45195,45174,45185,45181,45187,45182,45209,45188,45196,45191,45201,45192,45211,45197,45202,45198,45210,45205,45206,35056,35029,35057,36897,35625,38156,37860,38046,37685,38088,4460,6587,49655,49644,49645,49649,49647,49661,49650,49656,49653,49672,49654,49662,49659,49665,49660,49681,49666,49674,49669,49707,49670,49682,49677,49697,49678,49688,49685,49703,49691,49698,49692,49721,49704,49746,49710,49722,49715,49727,49716,49733,49728,49739,49734,49774,49742,49754,49748,49760,49751,49765,49757,49789,49767,49781,49773,49803,49782,49790,49785,49794,49786,49810,49796,49804,49799,49848,49800,49812,49807,49823,49808,49819,49815,49827,49816,49824,49820,49833,49828,49839,49834,49843,49840,49855,49844,49852,49847,49879,49854,49861,49857,49865,49862,49869,49866,49911,49872,49880,49875,49891,49876,49884,49882,49895,49887,49892,49888,49899,49897,49903,49901,49920,49904,49912,49907,49915,49908,49937,49918,49927,49922,49929,49925,49945,49930,49938,49933,49947,49934,49946,49941,49955,49942,49963,49950,49956,49951,49971,49952,49964,49959,49974,49960,49972,49967,49968,49977,49975,45214,45212,45224,45221,45216,45233,45217,45226,45218,45227,45222,45239,45228,45234,45231,45247,45232,45240,45237,45255,45238,45248,45243,45263,45244,45256,45251,45271,45252,45264,45259,45297,45260,45272,45267,45275,45268,45279,45276,45285,45281,45289,45286,45305,45290,45298,45293,45313,45294,45306,45301,45321,45302,45314,45309,45329,45310,45322,45317,45337,45318,45330,45325,45345,45326,45338,45333,45353,45334,45346,45341,45357,45342,45354,45349,45364,45350,45373,45358,45366,45361,45381,45362,45374,45369,45389,45370,45382,45377,45417,45378,45390,45385,45399,45386,45409,45393,45400,45394,45427,45403,45410,45404,45418,45413,45423,45414,45488,45424,45439,45430,45445,45433,45440,45434,45455,45446,45460,45449,45456,45450,45465,45459,45471,42242,45466,45477,45472,45485,45480,45507,45483,45491,45489,45495,45492,45499,45496,45515,45500,45508,45503,45518,45504,45516,45511,45512,45517,34074,34036,35657,35658,30796,37468,34652,35558,35666,35948,36103,36482,38162,38163,10448,38166,27533,38244,38246,35775,36410,36440,36607,37207,37888,49984,49979,49991,49981,49986,49982,50025,49992,49987,50003,49988,49999,49995,50001,49996,50009,50005,50013,50010,50017,50015,50033,50018,50026,50021,50037,50022,50034,50029,50040,50030,50043,50038,50075,50042,50047,50045,50051,50049,50055,50053,50065,50058,50069,50061,50066,50062,50080,50072,50091,50076,50083,50079,50106,50084,50092,50087,50095,50088,50099,50096,50109,50100,50108,50103,50127,50104,50113,50111,50118,50115,50135,50120,50128,50123,50143,50124,50136,50131) or 
/* deleted 62 similar lines */
procesid in (102606,102618,102613,102626,102614,102629,102621,102627,102622,102633,102631,102649,102634,102642,102637,102657,102638,102650,102645,102665,102646,102658,102653,102673,102654,102666,102661,102681,102662,102674,102669,102699,102670,102682,102677,102690,102678,102707,102685,102692,102686,102700,102695,102715,102696,102708,102703,102723,102704,102716,102711,102731,102712,102724,102719,102739,102720,102732,102727,102747,102728,102740,102735,102754,102736,102748,102743,102758,102744,102756,102751,102783,102752,102761,102760,102766,102763,102772,102768,102775,102770,102791,102776,102784,102779,102799,102780,102792,102787,102807,102788,102800,102795,102815,102796,102808,102803,102819,102804,102816,102811,102822,102812,102826,102820,102837,102824,102829,102828,102845,102830,102838,102833,102853,102834,102846,102841,102861,102842,102854,102849,102887,102850,102862,102857,102865,102858,102869,102866,102873,102870,102879,102874,102880,102888,102883,102884,101295,101287,101317,101288,101296,101291,101299,101292,101303,101300,101307,101305,101339,101310,101318,101313,101325,101314,101331,101321,101327,101322,101347,101332,101340,101335,101373,101336,101348,101343,101359,101344,101355,101351,101365,101352,101360,101356,101399,101366,101374,101369,101381,101370,101385,101377,101382,101378,101391,101387,101407,101392,101400,101395,101417,101396,101408,101403,101413,101404,101431,101414,101421,101418,101423,101419,101439,101424,101432,101427,101525,101428,101440,101435,101447,101436,101453,101443,101448,101444,101459,101454,101469,101460,101479,101463,101470,101464,101485,101473,101480,101474,101495,101486,101501,101489,101496,101490,101507,101502,101513,101508,101519,101514,101591,101521,101533,101528,101539,101534,101547,101540,101553,101548,101559,101554,101567,101562,101573,101568,101579,101574,101584,101580,101603,101582,101592,101587,101588,101596,101594,101604,101599,101607,101600,101611,101609,101615,101613,101619,101617,101625,101620,101631,101626,101638,101629,101635)
);

I had to remove 62 lines to stay under the 30000 characters limit, there used to be 66 procesid in (...)-lines, each containing 1000 IDs, and 1 containing fewer IDs.

A customer gets the "too many values" error, but I don't see how this query can cause that.

When I try to reproduce this, I run into different problems. SQL Developer gives a "No more data to read from socket" error and SQL*Plus gives "end-of-file on communication channel".

A smaller query with only 14 lines of procesid in (...) does work in SQL*Plus and SQL Developer, but adding a fifteenth line makes the error occur.

When I set autotrace traceonly explain in SQL*Plus the problem also occurs, so I guess it doesn't even get around to executing the query.

My questions are:

How can this query cause the "too many values" error?

Can the problems I have in reproducing the error somehow be related to that error?

Is there anything wrong with the statement?

I'm not sure which version of Oracle the customer has, but I'm using 11g r2.

  • Please add the entire error message, with code, verbatim, not your interpretation of it. – mustaccio Jan 29 at 13:35
  • You have 67 lines containing approximately 1000 ids each. Why not just put them in a list in a flat file, define an external table on the flat file and then join to the flat file. I feel like that would be so much easier. – BriteSponge Jan 29 at 14:24
  • Seriously ? How is that query constructed ? I can’t imagine it is hard coded that way. That would be total nonsense. So I imagine it is generated dynamically in some program. Where are this numbers (procesid) coming from ? From some other table ? From some file ? From some external process ? What is this query actually trying to achieve ? – Albert Godfrind Jan 30 at 4:37
  • Yes, I understand this query is horrible. And yes, it's dynamically generated. It's an improvement on a previous query which was static, but took minutes to complete. The current problem only arose because this specific database has been filled with crappy data. In normal operations, I don't often see more than 1000 IDs. That being said, this pathological situation alerted me to the limits of this solution, which is why I'm asking these questions. And fortunately Michael Klutz and Balazs Papp provided me with a solution that might very well work. – Miel Jan 30 at 7:29
5

DON'T DO THAT

That code is horrible.

You should place ALL of the values in a Global Temporary Table (GTT) and JOIN to that table.

Call commit or rollback to auto-clear the GTT.

  • I'll look into using GTT, sounds promising. As I understand this, I'll need to set up a GTT for this purpose like any other table, but the data stored in there are only visible to the current session, and will be dropped on commit (as long as I don't specify "ON COMMIT PRESERVE ROWS"). Is this correct? – Miel Jan 30 at 7:23
3

Is there anything wrong with the statement?

Yes, the 67 lines of IN lists with 1000 items, get rid of that.

Use a GTT, or a PL/SQL collection.

The last time I had to troubleshoot something like that, about 4 months ago, it looked like this:

Original query could not be executed after the database reached a high number of sessions, got the same errors you described: "No more data to read from socket" and "end-of-file on communication channel", the session we tried to run the query from was simply terminated without any other message, there was no record of it even in the database alert log.

After rewriting the query to use a GTT, inserting the list of IDs into the GTT took a few seconds, then running the query finished in about 10 seconds.

After killing the inactive sessions that were inactive for more than 1 day (hundreds of them), the database was able to execute original query, in 7 minutes, which was the expected execution time for that query, the developer said it never ran faster than that.

They still use the original query up to this day, and whenever they can not run the query or have too many inactive sessions, they just kill them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.