Skip to Main Content
  • Questions
  • No logon/connect in Forms 6 Application

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Sridevi.

Asked: February 09, 2001 - 9:11 pm UTC

Last updated: July 21, 2004 - 5:35 pm UTC

Version: 6

Viewed 1000+ times

You Asked

Hi Tom,
I have an Application created in Developer 6. I want the first form (it is a welcome screen) to appear without the user having to connect to any database. In other words the first screen of the application should be accessible to all and sundry. On clicking on a command button say "login" in this form, the logon screen should pop up.

At the moment I have created a dummy user with only "create session" privilige and I am opening my application with logon_screen=no and with the dummy user's userid. On clicking the "login" command button on the form, the logon screen is made to appear using "logon_screen". And then user validations are done.

To put it simply I want to know if in forms 6, is there an equivalent to the "nolog" parameter that we use open SQL*plus without connecting to any database?

Thanks in advance....

and Tom said...

If you make an ON-LOGON trigger such as:

DECLARE
un VARCHAR2(80);
pw VARCHAR2(80);
cn VARCHAR2(80);
begin
default_Value('NO','global.do_logon');

if ( name_in( 'global.do_logon' ) = 'NO' )
then
null;
else
un := Get_Application_Property(USERNAME);
pw := Get_Application_Property(PASSWORD);
cn := Get_Application_Property(CONNECT_STRING);
IF cn IS NOT NULL THEN
LOGON(un,pw||'@'||cn);
ELSE
LOGON(un,pw);
END IF;
end if;
end;


and then, in the when-button-pressed trigger:

:global.do_logon := 'YES';
execute_trigger( 'on-logon' );


you'll achieve what you desire.

Rating

  (5 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

BIG BUG

A reader, November 08, 2002 - 11:23 am UTC

Hi, TOm,

Until today, I found a very BIG BUG in the oracle form.
THat is when you run the form, the default logon window
OR log_on ptocedure can not catch the blank padded after
the username:
Username: "abcd "
Password: ....
connect string: "...."

The form let this logon info passed even there are lots
of spaces after the "abcd". This caused us lots of trouble
because we use the "GET_APPLICATION_PROPERTY(USERNAME)"
lots of times and store them in the DB---- with the blanks
padded after the real username. I mean we should not let the
logon username with the blanks padded passed, how can we do that?

Thanks


Tom Kyte
November 08, 2002 - 12:44 pm UTC

it is not a bug in forms -- it is a bug in your code.

You should have used rtrim( get_application_property(username) ) to trim it if that is what you need.

Connect to DB

A reader, November 08, 2002 - 12:59 pm UTC

Hi, TOm,
I can not agree with you.
Say, id you connect to DB by "abcd " instead of
"abcd", then you can not log into the DB.
How will you explain the difference?

Thanks and have a nie day


Tom Kyte
November 08, 2002 - 1:03 pm UTC

you don't have to agree with me -- however, unless and until you use rtrim -- you are hosed right?

ops$tkyte@ORA920.US.ORACLE.COM> connect scott    /tiger
Connected.
ops$tkyte@ORA920.US.ORACLE.COM>


hmm?  you could always use USER as well -- instead of get app property. 

Learn another thing from you

A reader, November 08, 2002 - 1:32 pm UTC

HI, TOm,

How did you get:
ops$tkyte@ORA920.US.ORACLE.COM> connect scott /tiger
Connected.
ops$tkyte@ORA920.US.ORACLE.COM>

mine is got error:

connect scott /tiger
Invalid option.
Usage: CONNECT <username> [AS SYSDBA|SYSOPER]
is it 9i diffenrent from 8i?

Ok, would you tell me the fact behind the scene that why
we allow blank padded username passed validation--why
get_application_property(username) doesn't auto trim the right space? Is it because we can create an user in DB with several blanks
padded? If so, why can't I log into DB either with
connect scott /tiger OR
connect "scott "/tiger?

My exsting system has lots of GET_APPLICATION_PROPERTY(USERNAME) both in forms and packages in DB, I don't want to
mofified them one by one? Are you tell me that GET_APPLICATION_PROPERTY(USERNAME) is not safe and we should always use USER? I mean that
the HELP system in the file should address that issue at least to the developer?

Thanks and have a nice day




Tom Kyte
November 08, 2002 - 2:13 pm UTC

JServer Release 8.1.7.4.0 - Production

ops$tkyte@ORA817DEV.US.ORACLE.COM> connect scott   /tiger
Connected.
ops$tkyte@ORA817DEV.US.ORACLE.COM>


PL/SQL Release 8.0.6.0.0 - Production

ops$tkyte@ORA806.WORLD> connect scott   /tiger
Invalid option.
Usage: CONNECT <username> [AS SYSDBA|SYSOPER]


looks like 8i and up is OK with this.

You can use get app property -- you just have to be aware that it returns what the user typed.  If trailing blanks are a problem -- you could add a trigger to the table:

...
   :new.userid_field := rtrim(:new.userid_field);
.....

and that'll fix all of the forms. 

Login Screen in the beginning

Raj, April 29, 2003 - 1:23 am UTC

Hi Tom,

I tried the sol. given above(Clicking the button and displaying the logon screen) but I have a similar problem.
Actually I want the default logon_screen to appear all the time whenever I access the application in the beginning itself.
I tried giving logon_screen built-in in preform I get only the logon screen but when I click connect it goes to the application without giving any error message even if I give the wrong password.

My requirement is
When I click the application the default screen should appear and I should connect to the database based on the informations I enter in the default logon screen or display an error if the data given is not correct.
If I click cancel it shoul exit the form

Pls. give me a solution.


Tom Kyte
April 29, 2003 - 8:03 am UTC

i don't code forms, haven't done so since about 1995 when this web thing came along. I can suggest you try otn.oracle.com under discussion forums -> developer. there you will find many people who use forms every day. they may be able to help.

A reader, July 21, 2004 - 5:35 pm UTC

Suppressing the default form logon is not a good idea when you connect to Oracle Data Source.

This is specially given for Non-oracle data sources.

Like You can connect to a non-oracle data source in on-logon trigger.




More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library