Toad World® Forums

QCTO and Q$ERROR manager


#1

I am using free software from QUEST called Quest Error Manager. In my application I am raising an error, defined by my self ( the number of error message is 9998 ) but I am not able to catch this error ( exception ) in QCTO. Please find sample of the code:

CREATE OR REPLACE PROCEDURE QUEST.OW_RISC (p_deljenec IN NUMBER,
p_delitelj IN NUMBER)
IS
tmpVar NUMBER;
tmpKolicnik NUMBER;
tmpOstanek NUMBER;
error_info q$error_manager.error_info_rt;
/******************************************************************************
NAME: OW_RISC
PURPOSE:

REVISIONS:
Ver Date Author Description


1.0 10.2.2010 Acimobile 1. Created this procedure.

NOTES:Procedura nadomesti deljenje z odštevanjem za naravna števila
Vrne tudi ostanek
Velja le za delitelj > 0

******************************************************************************/
BEGIN
tmpVar := 0;
tmpKolicnik := 0;
tmpOstanek := NVL(p_deljenec, 0);

IF NVL(p_delitelj, 0) <= 0 or NVL(p_deljenec, 0) < 0
THEN
Q$ERROR_MANAGER.Raise_ERROR (
error_code_in => 9998,
text_in => ‘Velja le za stevila > 0’,
name1_in => ‘Deljenec’,
value1_in => p_deljenec,
name2_in => ‘Delitelj’,
value2_in => p_delitelj
);
END IF;

LOOP
EXIT WHEN tmpOstanek < p_delitelj;
tmpOstanek := tmpOstanek - p_delitelj;
tmpKolicnik := tmpKolicnik + 1;
END LOOP;

DBMS_OUTPUT.PUT_LINE ('Kolicnik = ’ || tmpKolicnik);
DBMS_OUTPUT.PUT_LINE ('Ostanek = ’ || tmpOstanek);
EXCEPTION
WHEN OTHERS
THEN
q$error_manager.get_error_info (error_info);

  DBMS_OUTPUT.put_line (error_info.code || ' ' || error_info.name);
  DBMS_OUTPUT.put_line (error_info.text);
  DBMS_OUTPUT.put_line (error_info.recommendation);

END;
/

How should I create my test case for catch this error ??

Thanks and best regards!


#2

Hello Aci,

Nice to hear from you! Hope all is well in Slovenia. You post a very interesting question. QEM provides an overall API for error management, so generally when you handle an error you call the get_error_info procedure and then analyze the individual values returned. But I should probably make it easier than that.

First though I wonder: what sort of test have you already created, tried, and had trouble with?

Regards, SF


#3

Hi Steven. Thanks for asking I am well and also my coworkers.

In my procedure I raise an application error 9998 and then I handlethis error in exception when others.

I have created some cases where I test if this exception ( 9998 )occurs, but no results.

Regards!


#4

Aci,

The q$error_manager.get_error_info procedure returns these values:

PROCEDURE get_error_info (
code_out OUT q$error.code%TYPE
, name_out OUT q$error.name%TYPE
, text_out OUT q$error_instance.MESSAGE%TYPE
, system_error_code_out OUT q$error_instance.system_error_code%TYPE
, system_error_message_out OUT q$error_instance.system_error_message%TYPE
, recommendation_out OUT q$error.recommendation%TYPE
, error_stack_out OUT q$error_instance.error_stack%TYPE
, call_stack_out OUT q$error_instance.call_stack%TYPE
, environment_info_out OUT q$error_instance.environment_info%TYPE
);

So with QEM as currently designed, you need to call this procedure after the program executes (customization code), and then check the value of the variable into which code_out was placed.

What I will do, though, is add some functions to QEM to return JUST the error code, name, etc., so that you can simply evaluate the function return value as an expression test. How does that sound?

SF