Fórum ORA-06502 character string buffer too small numérico ou de valor #619821
12/04/2023
0
Fiz de tudo pra resolver. tentei converter a informação usnado convert, tentei to_char, mas nada funciona... Alguém consegue me ajudar?
select pac_reg Registro
,pac_nome Paciente ,checkcir.rcl_dthr, checkcir.rcl_txt
,replace(smart.f_resultado_rcl_2(relcir.rcl_laudo_tratado, 21156, 12), ''?'') Data_Cirurgia
,replace(replace(smart.f_resultado_rcl_2(relcir.rcl_laudo_tratado, 21155, 39), ''?''), ''Potencialmente conta'', ''Pontencialmente contaminada'') Potencial_Contaminação
,nvl(psv_nome, rcl_e_nome) Cirurgião
,ctf_nome Classe_Técnica_Proc_Principal
,esp_nome Especialidade_cirurgião
,smk_nome Procedimento_Principal
,decode(rcl_c_via_acesso, ''P'', ''Principal''
, ''N'', ''Outra via'') Via_de_acesso
,replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28803, 07), ''?'') Anestesista
,replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 26), ''?'') Ini_cir_timeout
,replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28806, 33), ''?'') Fim_cir_timeout
,replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 09), ''?'') Antibiótico_profilático
,case
when replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 09), ''?'') = ''Sim'' then
replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 13), ''?'')
end Qual_is
/*erro nesta coluna*/
,convert(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 14), ''US7ASCII'', ''WE8ISO8859P1'')
,case
when replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 09), ''?'') = ''Sim'' then
replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 14), ''?'')
end Horário_1a_dose
,case
when replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 09), ''?'') = ''Sim'' then
replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 15), ''?'')
end Horário_2a_dose
,(select max(ism.ism_data_aplicacao)
from ism
,sma
,bul
,bpt
where ism_sma_serie = sma_serie
and ism_sma_num = sma_num
and bul_mat_cod = ism_mat_cod
and bpt_bul_med = bul_med
and bpt_pat_cod in (''AMS'',
''CFZ'',
''CZL'')
and ism_qtde_baixa > 0
and sma_pac_reg = relcir.rcl_pac
and sma_hsp_num = relcir.rcl_hsp
and (ism_data_aplicacao - relcir.rcl_dthr) between 0 and 5) Últ_dose_Cefazoilna_Ampicilina
,(select max(ism.ism_data_aplicacao)
from ism
,sma
,bul
,bpt
where ism_sma_serie = sma_serie
and ism_sma_num = sma_num
and bul_mat_cod = ism_mat_cod
and bpt_bul_med = bul_med
and bpt_pat_cod in (''CXO'',
''CEM'')
and ism_qtde_baixa > 0
and sma_pac_reg = relcir.rcl_pac
and sma_hsp_num = relcir.rcl_hsp
and (ism_data_aplicacao - relcir.rcl_dthr) between 0 and 5) Últ_dose_Cefuroxima_Axetil
,pac_celular Celular_paciente
,pac_fone Telefone_paciente
,(select max(nvl(to_number(replace(replace(
smart.f_resultado_rcl_2(i.rcl_txt, 39321, 1)
, ''?''), '',0'' , '''')/1000), 0)) from rcl i where pac.pac_reg = i.rcl_pac and i.rcl_cod = ''45002'') peso
/*,to_char(relcir.rcl_dthr, ''HH24:MI:SS'') hora_entrada*/
,checkcir.rcl_dthr Entrada_do_Paciente_Na_Sala
,replace(smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28804, 18), ''?'') Inicio_inducao
from
(select rcl.*
,case
when rcl_laudo_rtf is not null and rcl_txt = ''NO_CAMPO_LAUDO_RTF'' then
convertlong_to_varchar(rcl_pac, rcl_tpcod, rcl_cod, rcl_dthr, rcl_hsp)
else
rcl_txt
end rcl_laudo_tratado
from rcl) relcir
,(select rcl.*
,case
when rcl_laudo_rtf is not null and rcl_txt = ''NO_CAMPO_LAUDO_RTF'' then
convertlong_to_varchar(rcl_pac, rcl_tpcod, rcl_cod, rcl_dthr, rcl_hsp)
else
rcl_txt
end rcl_laudo_tratado
from rcl where rcl_stat <> ''C'') checkcir
,rcl_ecp
,psv
,esm
,esp
,rcl_crg
,smk
,ctf
,pac
where relcir.rcl_pac = pac_reg
and relcir.rcl_id = rcl_e_id
and rcl_e_fec_cod = ''C''
and rcl_e_psv_cod = psv_cod
and psv_cod = esm_med
and esm_esp = esp_cod
and esm_default = ''S''
and relcir.rcl_id = rcl_c_id
and rcl_c_via_acesso in (''P'', ''N'')
and rcl_c_smk_tipo = smk_tipo
and rcl_c_smk_cod = smk_cod
and smk_tipo = ''S''
and smk_tipo = ctf_tipo
and smk_ctf = ctf_cod
and smk_cod not in (''2916'',''88020903'',''88021148'',''2549'',''7330'',''8802'',''2509'',''2132'',''2382'',''7311'',''6046'',''2051'',''8801'',''31162'',''8516'',''8819'',''2290'',''8726'',''2393'',''8670'',''31640'',''32699'',''31578'',
''3117'',''2043'',''7386'',''4923'',''2234'',''2452'',''9046'',''8794'',''2107'',''2133'',''31395'',''31342'',''9032'',''31638'',''31798'',''31747'',''6807'',''31663'',''8539'',''9695'',''6779'',''9694'',''31651'',''9693'',''3383'',''2367'',
''31642'',''31582'',''2450'',''2473'',''2324'',''8740'',''2206'',''2063'',''2041'',''9406'',''31166'',''2130'',''32473'',''8727'',''31035'',''5099'',''2136'',''31534'',''31533'',''2391'',''31173'',''2355'',''2373'',''2444'',''31174'',''8671'',
''2093'',''32471'',''31661'',''2356'',''2849'',''2481'',''2908'',''88020919'',''88020730'',''8946'',''31180'',''31181'',''31182'',''31183'',''31184'')
and relcir.rcl_cod = ''RELCIR''
and relcir.rcl_stat not in (''C'', ''A'')
and checkcir.rcl_pac = relcir.rcl_pac
and checkcir.rcl_hsp = relcir.rcl_hsp
and trunc(checkcir.rcl_dthr) = trunc(relcir.rcl_dthr)
and checkcir.rcl_cod = ''CHECKCIR''
and checkcir.rcl_stat not in (''C'', ''A'')
and relcir.rcl_dthr >= to_date ( ''2023-03-24 08:00:00'', ''yyyy-mm-dd hh24:mi:ss'' )
and relcir.rcl_dthr < to_date ( ''2023-03-24 23:59:59'', ''yyyy-mm-dd hh24:mi:ss'' )
Isnar Filho
Curtir tópico
+ 0Posts
12/04/2023
Arthur Heinrich
Como o seu código é um select, suspeito que o erro esteja ocorrendo internamente a alguma das funções chamadas na query.
Por exemplo: convertlong_to_varchar(rcl_pac, rcl_tpcod, rcl_cod, rcl_dthr, rcl_hsp)
Não sei o que esta função faz mas, pelo nome, pode ser aqui o problema.
Se você conseguir colocar a sua query dentro de um bloco PL/SQL, com tratamento de erro, do tipo:
set serveroutput on
begin
for row in (<query>) loop
null;
loop;
exception
when others then
dbms_output.put_line(dbms_utility.format_error_stack);
dbms_output.put_line(dbms_utility.format_error_backtrace);
end;
/
Talvez você obtenha uma mensagem mais clara de onde o problema está ocorrendo.
Gostei + 0
13/04/2023
Isnar Filho
deu um erro aqui
variavel de bindig "SS" não declarada
Rodei no developer do oracle, não sei se serve.
Eis o que sei até aqui:
O erro está na seguinte função:
smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 14)
Ela trata um bloco de texto gigante, algo parecido com "@#28804@13&Sim@#28804@3&Não @#28804@17&Sim@#28804@8OMANTA TÉRMICA SUPERIOR " e ele pega tudo tem entre uma determinada sequencia ex @#28804@13& e o proximo @. Inicialmente eu não identifiquei nenhum problema no momento que dá o erro, já até isolei a query na ferramenta que tenho disponível.
Como o seu código é um select, suspeito que o erro esteja ocorrendo internamente a alguma das funções chamadas na query.
Por exemplo: convertlong_to_varchar(rcl_pac, rcl_tpcod, rcl_cod, rcl_dthr, rcl_hsp)
Não sei o que esta função faz mas, pelo nome, pode ser aqui o problema.
Se você conseguir colocar a sua query dentro de um bloco PL/SQL, com tratamento de erro, do tipo:
set serveroutput on
begin
for row in (<query>) loop
null;
loop;
exception
when others then
dbms_output.put_line(dbms_utility.format_error_stack);
dbms_output.put_line(dbms_utility.format_error_backtrace);
end;
/
Talvez você obtenha uma mensagem mais clara de onde o problema está ocorrendo.
Gostei + 0
13/04/2023
Arthur Heinrich
deu um erro aqui
variavel de bindig "SS" não declarada
Rodei no developer do oracle, não sei se serve.
Eis o que sei até aqui:
O erro está na seguinte função:
smart.f_resultado_rcl_2(checkcir.rcl_laudo_tratado, 28805, 14)
Ela trata um bloco de texto gigante, algo parecido com "@#28804@13&Sim@#28804@3&Não @#28804@17&Sim@#28804@8OMANTA TÉRMICA SUPERIOR " e ele pega tudo tem entre uma determinada sequencia ex @#28804@13& e o proximo @. Inicialmente eu não identifiquei nenhum problema no momento que dá o erro, já até isolei a query na ferramenta que tenho disponível.
Bom. Já avançou um pouco. Se você tem a função que apresenta o erro, precisa examinar o código e entender onde está o problema.
Com base na sua descrição, você poderia fazer a busca inicial, identificando a posição de início da string '@#28804@13&', somando o tamanho da tag pesquisada e, em seguida, localizar a posição do próximo '@'.
tag := '@#28804@13&';
inicio := instr(message, tag)+length(tag);
fim := instr(message, '@', inicio);
valor := substr(message, inicio, (fim-inicio));
No exemplo acima, provavelmente a resposta seria 'Sim'. Mas, se não podemos garantir que a mensagem esteja íntegra e que respeite certos padrões, você precisará contornar eventuais falhas.
Por exemplo, se o valor esperado precisa ser de até 100 caracteres, um resultado de (fim-inicio)>100 indica um problema. Você pode tratar o problema retornando erro ou truncando o valor, fazendo:
valor := substr(message, inicio, least(fim-inicio, 100));
Ou algo do tipo.
Gostei + 0
13/04/2023
Arthur Heinrich
deu um erro aqui
variavel de bindig "SS" não declarada
Rodei no developer do oracle, não sei se serve.
O problema da bind variable pode estar relacionado aos parâmetros que a sua query utiliza...
replace(smart.f_resultado_rcl_2(relcir.rcl_laudo_tratado, 21156, 12), ''?'') Data_Cirurgia
... '?' ...
Para testar, a query precisa ser executada com todos os valores atribuídos.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)