Skip to Main Content
  • Questions
  • Want form to reconnect automatically following database restart

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Trevor.

Asked: June 08, 2001 - 12:36 pm UTC

Last updated: October 06, 2001 - 5:14 am UTC

Version: 6.0

Viewed 1000+ times

You Asked

I have a form that runs continuously in the background reading a table on the database at regular intervals and sending an email for each record that is found.

At present the form is closed down prior to bringing the database down for backup purposes, and restarted again after the database has been brought back up. This is done overnight via NT Scheduler. If the database crashes the form has to be manually stopped and started.

I've tried to get the form to re-logon automatically but get the error FRM-40029: Already logged on. I've placed the Logout built-in before the Logon but this doesn't seem to help.

The form can log itself back on if the session is killed, but fails when the database is bounced.

Can you help please?

Database is Oracle8i Enterprise Edition Release 8.1.6.0.0
JServer Release 8.1.6.0.0

For info, the basic code is as follows:
When-New-Form-Instance Trigger
:global.username := Get_Application_Property(USERNAME);
:global.password := Get_Application_Property(PASSWORD);
:global.connect_string := Get_Application_Property(CONNECT_STRING);

When-Timer-Expired Trigger (every ten seconds)
begin
select sysdate into :GLOBAL.dummy from dual;
exception
when others then
logout; -- in case session still thought to be logged on !!
logon(:global.username, :global.password||'@'||:global.connect_string, false);
end;


and Tom said...

Do you have any problems with doing this in the database instead? in that fashion, it'll only run when the database is up and there is no complex process OUTSIDE of the database.

See
</code> http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:255615160805 http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:1522605935209 <code>

for getting java mail loaded into the database (heck -- plsql with UTL_SMTP can do this easily as well -- search for utl_smtp on my site for details)

I wouldn't do this in forms at all.

If you do do it in forms -- perhaps I would log out and log back in each time, since its in the background that'll work out fine.

DBMS_JOB + a stored procedure is the way to do it though.



followup to comment

You haven't loaded java into the database.

$ORACLE_HOME/javavm/install/initjvm.sql




Rating

  (3 ratings)

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

Comments

Thanx - but now problem loading plsql.jar

Trevor, June 27, 2001 - 12:16 pm UTC

I encountered the error ORA-29540 when using UTL_SMTP and my dba attempted to load plsql.jar, as per your reply to a previous question, with the following result:

D:\>cd d:\orant816\plsql\jlib

D:\orant816\plsql\jlib>loadjava -user sys/sys plsql.jar
Error while retrieving errors for oracle/plsql/net/TCPConnection
ORA-00904: invalid column name

Error while retrieving errors for oracle/plsql/net/InternetAddress
ORA-00904: invalid column name

Error while creating resource META-INF/MANIFEST.MF
ORA-29547: Java system class not available: oracle/aurora/rdbms/Compiler

loadjava: 3 errors

D:\orant816\plsql\jlib>

Can you please help!

Trevor, October 05, 2001 - 11:08 am UTC

After one or two problems the dba managed to load initjvm.sql and all is well, thankyou.

An additional piece of information please..
Is it possible to include an attachment (eg. a txt file) with an email sent using utl.smtp? If so, how?

Tom Kyte
October 05, 2001 - 12:02 pm UTC

You would have to mime-encode it yourself. The easiest way to send emails with attachements is using the JavaMail API. See

</code> http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:255615160805 <code>

for details.


A reader, October 06, 2001 - 5:14 am UTC

My db is oracle 731, on vms-vax, client winNT4, forms5

my application, periodically (say 5 minutes) looking FTP server direcotry for data files, transfer it to local pc, proceessing, posting new datafile into FTP. This is my scnario. I'm using timer-expired trigger for this.

Here i had a problem. If the oracle server is down, then i need to restart my form again. Is on-logon will workout for me, to logoff and logon?.

How can i overcome this?

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