Toad World® Forums

Writing Java stored procs for Oracle within Toad?


#1

Hello…

I’m using Oracle 11g R2 enterprise edition and Toad (10.6.1.3 with DB admin module) and I would like to write some Java classes within oracle db…

but, when I right-click on the editor pane, I can choose only ‘SQL’, ‘PL/SQL’, ‘Text’, HEX’ and ‘RMAN’ tab types…
how could I enable Java in my Toad?

t


#2

Write it under pl/sql as you would write a pl/sql procedure. What you choose is
only the „style” of the editor, nothing stops you from writing
pl/sql under SQL for example.


#3

You would use the PL/SQL editor. You would write it something like:

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED “TestJava” AS

public class TestJavaStuff {

public static void doInvoke () {

Integer i_var = new Integer ( 10 );

Double d_var = new Double ( java . lang . Math . PI );

d_var = new Double ( 2.0 * d_var . doubleValue ());

for ( int i = 0 ; i

System . out . println ( “Write Something OUT from TestJavaStuff” );

}

return ;

}

}

/


#4

Interesting, very interesting:

Open a new HEX style tab in the MOE, then paste a short “select * from
dual;” statement.
Do you see what I see?
:slight_smile:

Cheers,
Norm [TeamT]

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should still check any attachment before opening it.
We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.

If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk


#5

I’m thinking that the OP would be looking for a specific Java type tab
so that there would be Java code highlighting?

Personally, for Java, which I hate, I use the HEX style editor tab!
Makes Java much better - it won’t compile! :wink:

Cheers,
Norm. [TeamT]

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should still check any attachment before opening it.
We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.

If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk


#6

Hey now…don’t be layin’ the smackdown on java. It has plenty of uses…the best one is inside my Dilbert coffee cup.

Since it looks and acts like a PL/SQL object, we just use the PL/SQL tab for it and provide java syntax highlighting there. A “java” tab would still have to provide the highlighting for the PL/SQL portion so it would be a duplicate of the PL/SQL tab.

Greg

Disclaimer:
It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shakes, the shakes become a warning.
It is by caffeine alone I set my mind in motion.


#7

Hi Greg,

On 24/03/11 12:12, Gregory Liss wrote:

Hey now…don’t be layin’ the smackdown on java. It has plenty of
uses…the best one is inside my Dilbert coffee cup.

No, sorry, I disagree. I hate Java.

  • Java the language - I hate it. It is dire, and slow!

  • Java the coffee (12,648,430) - waaaaay to strong and bitter for me.

  • Java the country. Never been there, can’t say if I like it or not! :slight_smile:

The worst of all of these is java, the language. Just say no!


Cheers,
Norm. [TeamT]


#8

take this simple example
public Class CREATE TYPE BODY NormsFavouriteJavaClass AS

MEMBER PROCEDURE NormsFavouriteJavaProcedure IS
g BINARY_INTEGER;
BEGIN
g := NormsFavouriteJavaClass.gcd(numerator, denominator);
numerator := numerator / g;
denominator := denominator / g;
END NormsFavouriteJavaProcedure;
END;
/
show errors
public class NormsFavouriteJavaClass
{
public static int gcd(int x, int y)
{
if (x

if (x % y == 0) return y;

return gcd (y, x / y);
}
}

Martin Gainty


Jogi és Bizalmassági kinyilatkoztatás/Verzicht und
Vertraulichkeitanmerkung/Note de déni et de confidentialité

Ez az üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.

Ce message est confidentiel et peut être privilégié. Si vous n’êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l’expéditeur. N’importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l’information seulement et n’aura pas n’importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.