Home » Developer & Programmer » Forms » using EXEC_SQL.Is_Connected (Forms 6i)
using EXEC_SQL.Is_Connected [message #325063] Wed, 04 June 2008 23:19 Go to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

Programaticaly i run the logout; procedure on a button press and the user is sent to a customized LOGIN form. but still when i test the using EXEC_SQL.Is_Connected flag, it returns true.

What i intend to do is:
Create a customized Login Form (instead of the default logon_screen) and allowing the user to connect to the oracle DB & when login out, it should be disconnected from the DB.
Re: using EXEC_SQL.Is_Connected [message #325066 is a reply to message #325063] Wed, 04 June 2008 23:25 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
OK, please proceed.

By the way, Forms6 has not been supported this century.

>still when i test the using EXEC_SQL.Is_Connected flag, it returns true.

What harm is done by the above?
Re: using EXEC_SQL.Is_Connected [message #325077 is a reply to message #325066] Wed, 04 June 2008 23:48 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

can you guide what logic i should be following to achieve it?

the form provides to fields (plz refer to the attached snap)
the TNS name is hard coded behind.

when the signin is pressed, the user is authenticated via logon function, then i examine the value of is_connected flag, which then returns true. and the user is redirected to another form.

but when the user is logs out (via logout) the flag still represents the value "true" and even if wrong user name/password is given (2nd time loggin in)the user is redirected to the main form.

so what actually i should test to see if the user is authorized or not.

Re: using EXEC_SQL.Is_Connected [message #325080 is a reply to message #325063] Wed, 04 June 2008 23:54 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
>even if wrong user name/password is given (2nd time loggin in)the user is redirected to the main form.
This smells like an implementation issue.
Upon presentation of LOGIN form, why not NULL out the password & enforce password validation before proceeding?
Re: using EXEC_SQL.Is_Connected [message #325089 is a reply to message #325080] Thu, 05 June 2008 00:15 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

can u please elaborate a bit more.
thanks
Re: using EXEC_SQL.Is_Connected [message #325109 is a reply to message #325080] Thu, 05 June 2008 01:00 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

anacedent wrote on Thu, 05 June 2008 09:54
>even if wrong user name/password is given (2nd time loggin in)the user is redirected to the main form.
This smells like an implementation issue.
Upon presentation of LOGIN form, why not NULL out the password & enforce password validation before proceeding?


i would like to add that,

2nd time when user go inside, opening new forms and navigation is open, however when F8/execute_query is initiated then forms show the Error message, that connection to database is required.

so when users logs out (logout;) the is connected flag does not represents the current connection status correctly.

here is a sample code
=========================
PROCEDURE LOGIN_OUT IS
pl_id paramlist;
COUNTER NUMBER := 0;
SALES_FORM_COUNT NUMBER := :global.sales_counter;
BEGIN
		
		CLS_FORM('NAME_COMP_MOTOR');
		CLS_FORM('ITEMS');
		CLS_FORM('PURCHASE_FORM');

	FOR counter IN 0..SALES_FORM_COUNT LOOP	
  	CLS_FORM('SALES_FORM');
	END LOOP;

		CLS_FORM('SALES_FORM');		
		CLS_FORM('ACCOUNTS_FORM');		
		CLS_FORM('TRANS');
		CLS_FORM('RENT_A_BIKE');
		--CLS_FORM('MAIN_FORM');
                logout;
		
	
	pl_id := Get_Parameter_List('FRM');
	IF NOT ID_NULL(PL_ID) THEN
		DESTROY_Parameter_List(PL_ID);
	END IF;
		
	PL_ID := Create_Parameter_List('FRM');			
	Add_Parameter(PL_ID,'DIRPATH',TEXT_PARAMETER,:GLOBAL.DIR);	
	NEW_FORM(:GLOBAL.DIR||'LOGIN_FORM.fmx',TO_SAVEPOINT,NO_QUERY_ONLY,NO_SHARE_LIBRARY_DATA,PL_ID);	
	
END;

=======================

CLS_FORM PROCEDURE IS AS FOLLOWS

==========================
PROCEDURE cls_form(frmname in varchar2) IS
form_id formmodule;
BEGIN
  FORM_ID := find_FORM(FRMNAME);	
	IF NOT ID_NULL(FORM_ID) THEN				
		CLOSE_FORM(FORM_ID);
	--	GO_FORM(FORM_ID);
	END IF;
END;

[Updated on: Thu, 05 June 2008 01:10]

Report message to a moderator

Re: using EXEC_SQL.Is_Connected [message #335387 is a reply to message #325109] Tue, 22 July 2008 01:02 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Have you solved your problem?

David
Re: using EXEC_SQL.Is_Connected [message #337169 is a reply to message #335387] Wed, 30 July 2008 01:39 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

not yet.

currently, m just closing the application when the users log out. will work over it lator. if you find some solution, please do inform thanks.
Re: using EXEC_SQL.Is_Connected [message #339561 is a reply to message #337169] Thu, 07 August 2008 18:34 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
With what part of 'exit_form' are you having a problem? When the form is closed the connection with the database will be terminated.

David
Re: using EXEC_SQL.Is_Connected [message #340442 is a reply to message #325063] Tue, 12 August 2008 22:29 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

In the code above.

after closing all other form except the main main form.

i call the logout; proceedure.
(this should disconnect from the database)

then i use the New_Form proceedure to open the Login form. (this closes the main form )

now the is_coonected flag should be false this time, but still it shows true and the user log inside to the application even if wrong user name and password is given. (seems as the user still connected to the application.)
Re: using EXEC_SQL.Is_Connected [message #341427 is a reply to message #340442] Mon, 18 August 2008 19:33 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
What code do you have that is populating the 'is_coonected flag'?

David
Re: using EXEC_SQL.Is_Connected [message #341671 is a reply to message #325063] Tue, 19 August 2008 21:59 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

please read the code below
======================
note:- currently as i mentioned that m just closing all forms on pressing of log out button.

earlier when i was (as discussed above) calling the login form via new_form procedure, its code is marked in comments
DECLARE
  pl_id         paramlist;
  username      varchar2 (255);
  userpass      varchar2 (255);
  connstring    varchar2 (255);
  isconnected   boolean        := FALSE;
BEGIN
--      logout;

--      EXEC_SQL.Close_Connection();
/*
        get_connect_info(username,userpass,connstring);
        message(username||'/'||userpass||'@'||connstring);
        message(username||'/'||userpass||'@'||connstring);
        */
  logon ('', '');
--      login();
  isconnected  := EXEC_SQL.Is_Connected ();
  if (isconnected) then
/*
        message('connected');
        message('connected');
*/
    begin
      PL_ID  := Create_Parameter_List ('FRM');
      Add_Parameter (PL_ID, 'DIRECT', TEXT_PARAMETER, 'NO');
      Add_Parameter (PL_ID, 'DIRPATH', TEXT_PARAMETER, :PARAMETER.DIRPATH);
      NEW_FORM (:PARAMETER.DIRPATH || 'MAIN_FORM.fmx',
                TO_SAVEPOINT,
                NO_QUERY_ONLY,
                NO_SHARE_LIBRARY_DATA,
                PL_ID);
    end;
  else
    message ('! connected');
    message ('! connected');
  end if;
exception
  when EXEC_SQL.Invalid_Connection then
    message ('Sorry invalid username / password');
    message ('Sorry invalid username / password');
    clear_form;
END;

the above code fires when the user preses the signin button after filling the usename & password from the login form.
[EDITED by DJM: fixed crappy formatting]

[Updated on: Thu, 21 August 2008 00:52] by Moderator

Report message to a moderator

Re: using EXEC_SQL.Is_Connected [message #341718 is a reply to message #341671] Wed, 20 August 2008 01:49 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Your 'close_connection' is commented out. What other code do you have for closing a connection?

David
Re: using EXEC_SQL.Is_Connected [message #341832 is a reply to message #341718] Wed, 20 August 2008 08:43 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

for simplicity consider two forms.

1. login form,
2. the welcome /main form (with log out button)

in both forms the evet occurs on button pressing.

login form has a sign in button.

welcome form has log out button.

the last code which i wrote is executed when the sign in button will be pressed.
(note it will be fired in two casses :
a: user login for the forst time
b: user login, logout, then login
login ==> welcome form ==> logout button ==> login form ==> re logins
)

======================
when the user presses the logout button (on welcome form) i programaticaly close all other forms (sales form can be opened several times and a global couter tracks the sales form cout - for the rest forms, they are restricted to be open of maximum 1 time) after closing all forms call to procedure logout is executed. then the new_form procedure is used to call the login form and one cycle completes.
==========================

since as i mentioned that i could not solve the problem the current code behind the logut button closes all forms along with welcome form and does not invokes the login form (thats y i've commented the close connection statement)
Re: using EXEC_SQL.Is_Connected [message #341999 is a reply to message #341832] Thu, 21 August 2008 00:59 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Okay, then show us the code in the 'logout' procedure of the 'welcome' form.

David
Re: using EXEC_SQL.Is_Connected [message #343097 is a reply to message #341999] Tue, 26 August 2008 05:00 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

the current code behind the Logout Button on welcome form is (i call this proceedure) :

PROCEDURE LOGIN_OUT IS
COUNTER NUMBER := 0;
SALES_FORM_COUNT NUMBER := :global.sales_counter;
isconnected boolean;
BEGIN
		
		CLS_FORM('NAME_COMP_GAMES');
		CLS_FORM('ITEMS');
		CLS_FORM('PURCHASE_FORM');

	FOR counter IN 0..SALES_FORM_COUNT LOOP	
  	CLS_FORM('SALES_FORM');
	END LOOP;

		CLS_FORM('SALES_FORM');		
		CLS_FORM('ACCOUNTS_FORM');		
		CLS_FORM('TRANS');		
		CLS_FORM('MAIN_FORM');
	
END;

==============
m closing the welcome form ( CLS_FORM('MAIN_FORM'); ) as RE-LOGIN was not working correctly.
===============

the current code behind the login form sign in button is :


	DECLARE
	pl_id paramlist;
	username varchar2(255);
	userpass varchar2(255);
	connstring varchar2(255);
	isconnected boolean := FALSE;
BEGIN

--	logout;
	
--	EXEC_SQL.Close_Connection();
/*	
	get_connect_info(username,userpass,connstring);	
	message(username||'/'||userpass||'@'||connstring);
	message(username||'/'||userpass||'@'||connstring);	
	*/	
	logon('','');
--	login();	

	isconnected := EXEC_SQL.Is_Connected();
	if (isconnected) then
/*
		message('connected');
		message('connected');
	*/
		begin
			PL_ID := Create_Parameter_List('FRM');		
			Add_Parameter(PL_ID,'DIRECT',TEXT_PARAMETER,'NO');
			Add_Parameter(PL_ID,'DIRPATH',TEXT_PARAMETER,:PARAMETER.DIRPATH);
			NEW_FORM(:PARAMETER.DIRPATH||'MAIN_FORM.fmx',TO_SAVEPOINT,
   NO_QUERY_ONLY,NO_SHARE_LIBRARY_DATA,PL_ID);	
		end;
	else
		message('! connected');
		message('! connected');
	end if;	
	
exception when EXEC_SQL.Invalid_Connection then
	message('Sorry invalid username / password');
	message('Sorry invalid username / password');
	clear_form;
	
END;

[EDITED by DJM: fixed 'too long' line]

[Updated on: Mon, 01 September 2008 00:57] by Moderator

Report message to a moderator

Re: using EXEC_SQL.Is_Connected [message #344688 is a reply to message #343097] Mon, 01 September 2008 00:58 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Where is the 'login_out' procedure? What is 'cls_form'?

David
Re: using EXEC_SQL.Is_Connected [message #345336 is a reply to message #325063] Wed, 03 September 2008 02:17 Go to previous messageGo to next message
itech
Messages: 168
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

the first code in my last post was of Login_out procedure...

the CLS_From code is below, this procedure closes the indicated form.

PROCEDURE cls_form(frmname in varchar2) IS
form_id formmodule;
BEGIN
  FORM_ID := find_FORM(FRMNAME);	
	IF NOT ID_NULL(FORM_ID) THEN				
		CLOSE_FORM(FORM_ID);
	--	GO_FORM(FORM_ID);
	END IF;
END;
Re: using EXEC_SQL.Is_Connected [message #345342 is a reply to message #345336] Wed, 03 September 2008 02:44 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
What is the name of the 'welcome' form?

David
Previous Topic: How to get Screen Resolution?
Next Topic: WHEN-NEW-ITEM-INSTANCE fires too late
Goto Forum:
  


Current Time: Fri Dec 09 04:17:07 CST 2016

Total time taken to generate the page: 0.20356 seconds