Toad World® Forums

Is it possible to directly edit a FUNCTION in "Source" tab?


#1

I connected successfully to an Oracle database, then listed all available
functions on the left, then selected one of the functions and placed the
cursor somewhere into the source code on the “Source” tab editor on the
right.

But much to my surprise I could not change the source code.

Is directly editing not possible?

Ben

View this message in context: http://old.nabble.com/Is-it-possible-to-directly-edit-a-FUNCTION-in-"Source"-tab--tp27520325p27520325.html
Sent from the TOAD mailing list archive at Nabble.com.


#2

You have to send it to the editor to edit it. You can do that with the 2nd
button on the toolbar.


#3

Ben,

You don’t directly edit the code in the source window. A few versions ago,
all editing was combined into a single editor. There are two icons that will get
you code to the editor, as well as double clicking on the item on the left hand
side (lhs).

HTH

chris
image001.jpeg


#4

Open the function in the editor. You can edit it from there.


#5

Ok, thank you.
But after editing: How can I (permanently) save the changed code?

Ben

Jeff Smith-7 wrote:

Open the function in the editor. You can edit it from there.


#6

What do mean by permanently saving the code?

You do NOT SAVE code in Oracle. You COMPILE the function, package, view, etc. Toad shows you what the source looks like but only because the Oracle data dictionary makes it possible because it keeps a copy of the source.

You SAVE source in a source repository.

So if you mean you want to make a change and then compile it,
Then execute the CREATE OR REPLACE statement which was included in the source.

BUT make sure you SAVE it somewhere also because anybody can change it in Oracle.


#7

#8

Morning Ben,

But after editing: How can I (permanently) save the changed code?

Ok, in Toad, by default, when you double-click a function (for example)
in the Schema Browser (SB), it will open in the editor (MOE - Mother Of
all Editors!) and allow you to edit it, and when you press F9 to compile
it, the following happens:

  • Your new code is loaded into the database in USER/ALL/DBA_SOURCE with
    your changes made;
  • Your code OVERWRITES the previous version of the code;
  • Your code is compiled.

This is not a good thing because in a test or production (or QA)
database, people shouldn’t be changing code willy nilly without some
form of change control process. A development database is the place to
‘play’ with code.

Toad has an option (View->Toad Options->Edit/Compile then “Allow
compiling when source loaded from database”. If that option is checked,
you can change code in the database willy nilly. If unchecked you are
prevented from compiling - the latter option (unchecked) is best for
test/qa/production databases as it prevents you inadvertently making
changes to live systems.

So, how do you compile code if the option is unchecked?

You double-click as above to open the code in the MOE, save it to a file
or files (in the case of a package and its body) and now you can compile
it.

You may also check it out from a source code system (I use subversion)
to make sure you have the latest version, open the file in Toad, edit,
compile, repeat, check back in when done and tested. Your test/qa people
can now check out the latest code, compile it against their own
database(s) and check that your work is acceptable and then it can be
processed on the production database(s).

This source control method means that in the event of a foul up, the
previous version can be obtained and re-compiled to undo the broken
changes.

The method whereby you save the file to disc and then compile is not so
good because you don’t have a previous version to go back to.

So, you see, saving the code you changed isn’t as simple a task as at
first thought. This applies to whether you use Toad to make the changes
or SQL*Plus or whatever else you happen to have handy. For any live
system, some form of code control is a must!

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

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