I'm trying to catch exception in a postgresql stored procedure. Without my "exception when other", my procedure is working. But don't with it.
This is my code :
create or replace function test(aaa varchar)
returns table (mmm integer, xxx integer)
as $body$
declare
ccc varchar(250);
ddd integer;
xxx integer;
mmm integer;
begin
select
srv_int_id
into
mmm
from
srv_service
where
srv_var_nom = aaa;
ddd := 1/0;
xxx := test2(9000,'AAA');
return query select
xxx,
mmm;
exception
when others then
select ccc = 'Erreur ' || sqlstate || ' dans la procedure test.sql';
return query select 0,0;
end;
$body$ language plpgsql;
On Squirrel, I hava this error
Error: ERREUR: la requête n'a pas de destination pour les données résultantes Indice : Si vous voulez annuler les résultats d'un SELECT, utilisez PERFORM > à la place. Où : fonction PL/pgsql p_ech_mes_lire_info_message(character varying), ligne > 44 à instruction SQL SQLState: 42601 ErrorCode: 0
But I don't understand it. Do you have an idea ? Thanks.