Home » Developer & Programmer » Forms » To Trap TNS Error
To Trap TNS Error [message #120173] Wed, 18 May 2005 02:59 Go to next message
karthi
Messages: 42
Registered: December 2000
Location: B'lore
Member

Hi All,

I'm running a D2k Form(.fmx), it shows erro msg as "TNS failed". This error shows because I might have lost connection with the database, etc. Now Whts my doubt is... I want to track(trap) the TNS failed Error Msg and to give my own message, so that user can understand easily. Thanx.

--Karthik
Re: To Trap TNS Error [message #120175 is a reply to message #120173] Wed, 18 May 2005 03:08 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have a look at the ON-ERROR trigger in the Forms Reference Manual.

Quote:

On-Error Trigger examples
Example
The following example checks specific error message codes and responds appropriately.
DECLARE
lv_errcod NUMBER := ERROR_CODE;
lv_errtyp VARCHAR2(3) := ERROR_TYPE;
lv_errtxt VARCHAR2(80) := ERROR_TEXT;
BEGIN
IF (lv_errcod = 40nnn) THEN
/*
** Perform some tasks here
*/
ELSIF (lv_errcod = 40mmm) THEN
/*
** More tasks here
*/
...
...
ELSIF (lv_errcod = 40zzz) THEN
/*
** More tasks here
*/
ELSE
Message(lv_errtyp||'-'||to_char(lv_errcod)||': '||lv_errtxt);
RAISE Form_Trigger_Failure;
END IF;
END;


Work out which erorr code you want change, trap it, and issue your own message.

David
Re: To Trap TNS Error [message #120203 is a reply to message #120175] Wed, 18 May 2005 07:13 Go to previous messageGo to next message
karthi
Messages: 42
Registered: December 2000
Location: B'lore
Member

Hi David,

ON-Error Trigger runs after connecting to the Oracle Database.
But whts my doubt is...
1. I have shutdown the Oracle Database or system got restarted.
2. At tht time when I try run the Form(.fmx), it is giving error as "TNS:unable to connect to destination (12203)".
3. I don't know the oracle error code for the above error, so how to trap this and to give user message.

bye
karthi
Re: To Trap TNS Error [message #120206 is a reply to message #120203] Wed, 18 May 2005 07:24 Go to previous messageGo to next message
karthi
Messages: 42
Registered: December 2000
Location: B'lore
Member

Hi David,

ON-Error Trigger works.
Whts my doubt is...
If network is down while starting the Form or on the half, then how to trap tht error and give error message to user...tht "Network is Down"

bye
karthi
Re: To Trap TNS Error [message #120302 is a reply to message #120206] Wed, 18 May 2005 19:25 Go to previous message
danosw
Messages: 20
Registered: May 2005
Location: California
Junior Member
We trap are users logon with:
--- ON-ERROR trigger
BEGIN
if error_code in ( 12154, 12203) then
message('Logon failed: Please check the database name.');
elsif error_code in ( 1017 ) then
message('Logon failed: Please verify your username and password.');
else
message(error_code||' '||error_text);
end if;
END;

--------
If you want to start forms without connecting to the database:

1) setup form to start without login.
code ON-LOGON at form level to:
null;

2) Do the login, and trap the error.
LOGON_SCREEN examples

/*

** Built-in: LOGON_SCREEN
** Example: Use the default Form Builder logon screen to prompt
** for username and password before logging on to
** the database. This uses the 'Get_Connect_Info'
** procedure from the GET_APPLICATION_PROPERTY
** example.
*/
DECLARE
un VARCHAR2(80);
pw VARCHAR2(80);
cn VARCHAR2(80);
BEGIN
/*
** Bring up the logon screen
*/
Logon_Screen;
/*
** Get the username, password and
** connect string.
*/
Get_Connect_Info( un, pw, cn );
/*
** Log the user onto the database
*/
IF cn IS NOT NULL THEN
LOGON(un,pw||'@'||cn);
ELSE
LOGON(un,pw);
END IF;
END;
Previous Topic: Record Group Problem
Next Topic: ora_ffi working example req
Goto Forum:
  


Current Time: Fri Sep 20 06:44:10 CDT 2024