Hello out there in data land. My name is Robert Pound and I am a product technologist from Quest. Today we will discuss code analysis rules in Toad for Oracle.
In a previous video, we saw how to use code analysis. Now let's take a look at how to create custom rules and rule sets for your organization. If you already do not have the dashboard open, you can come to database, diagnose, and code analysis to get to the dashboard that you see now on screen.
At the top near the dropdown for the rule sets, there are two icons, the edit rule sets and edit rules. So let's take a look at edit rules first. In the new dialog box, we can see all the rules in the rules universe. The test code for each one of the rules and then the categories as well as the actual XPath expression for each one.
So at the top, we have an import and export. So if you want to export a specific rule, you can select it and then export it out as an XML file and name it. And you also obviously have the ability to import those rules if you have new custom rules that you want to import into your Toad environment.
You also have the ability to modify existing rules. So if I choose to modify one of these rules, I can come up to edit. And let's just say I inadvertently wiped out the expression in this particular rule.
It will not allow me to have it blank but let's just say I entered in something that didn't make any sense. And now this rule has been modified. If I wanted to revert back to the old rule, I can click on the rule and then choose this icon here, which will restore the original version.
And I say yes, I want to revert back. And now it's back to the way it was. So that dialog box opens up for both creating new rules. So if you want to create a new rule, you can come to the top and choose new. And it will be blank and you can start from scratch.
The test code window is filled with all the excerpts from all the test codes. So it's a long list, but it allows you to use any or all of the test code snippets. Another way is to clone an existing rule. So let's say you want to modify something but you don't necessarily want to lose the original rule.
You can choose clone and that will bring in the contents of the rule. But it's going to create a new rule item. So currently, this rule is 2,113. But when we clone this and create a new rule, it will be 7,001, I believe. To modify rules, you have to be familiar with XPath. But to get you started.
So the tips and description, obviously just text. And you have your choice per drop downs as far as severity, objective, and category. But the actual magic behind the scenes is the XPath expression.
So the way it works is you have a piece of test code that you either wrote or you borrowed from the environment. So to take a look at this, we come up here and click the XML code sample. So what this is going to do is show you the XML version of this code.
So we can see there's a select column one, two, and three. And in the code, we can see select list, select list item, column one, column two, column three. So what XPath does, it's the way to interpret and select XML documents. So that's just a brief overview to get you started.
And when you make modifications, you can come up here and check this to test the rule and it will actually run the rule. So obviously, for this default rule, it should flag this and it has. Let me go ahead and cancel this.
You can search. So if you're looking for a specific rule, you can type in something like alias and it will allow you to see only those rules that have alias in them, et cetera. Moving on to the rule sets.
So the rule sets are more straight forward. So you have your default rule sets. And in the case of the rule sets, they are not editable. You can see they are read-only. So the default rule sets you can not modify in any way. But you can clone them, similar to the rules themselves.
So if you clone a rule set, you have to give it a title. And then you can select and deselect whichever rules you want to apply for this particular rule set. And again, you can search in this rule set for anything that you're looking for. Let me go ahead and cancel this out.
And in addition to being able to import and export your custom rule sets, you can also delete and modify them, whereas the default rule sets you can only export them out. You also have the ability to import and export to Toad Intelligence Central Server if you have that connection established.
So obviously, I've already published this out to Toad intelligence Central Server but that ability is there as well. And that is pretty much it for the rules and the rule sets.
Hopefully this video helped you understand a little bit about custom rules and rule sets in Toad for Oracle and code analysis. For more information, you can check out the help content. That has a wide range of information including code analysis and tutorials.
You can also check out the community driven innovation going on at www.toadworld. I encourage you to log in to the tool so you can get content specific to Toad for Oracle. For more information on this product, visit www.quest.com/products/toadfororacle. Thank you and have