Now I’ve got 3.1.5 I’d like to add some more automation.
Currently using Oracle 9, will shortly be using Oracle 10 in parallel.
I need to generate separate files for various parts of the DDL, eg tables, views, functions, etc.
I can create OTPs for each file and manually generate but I’d like to add a button to the form that loaded and generated each of a number of specified OTP selections in turn.
It would also need to manipulate the file name and add additional items to the script such as SPOOL command at the start.
I had achieved something like this in the earlier commercial version (but I had to edit TDM system scripts).
Can you give me some idea on how to do;
loading of OTP selection from code
creating a script in a user package that will be run from the form button
please accept my apologies for the delay. To your questions:
Loading of stored OTP selections (from XML file) from code is not available in the current version. I added your change request to our system. (CR# 47449). It is almost fixed and should appear in some future version of TDM3.
Please see the Manual (Help | Manual), topic “Customization Sample | Calling existing script from model properties form”.
The drawback of this approach is that you cannot use your saved Selected OTP settings, instead you create a completely new setting for each Generation “session” in the script. On the other hand, I believe this is exactly what you want.
Do you have the same script as in the new Package? Or do you have your own based on the template?
I took the new package and added my additional code to it.
When that didn't work I went back using the new package as supplied.
When that didn't work I conatcted you
According to my investigation the problem is the wrong specification of the generated file.
Unlike in the former TDM version, the latest version tries to save the generated file to the disk in the Generation method:
In script PERCodeGenerator, method Generate,
…
DDLScript.SaveToFile();
…
Now if you specify a wrong file name (non existent Path) and you are on the Generator form, the GetFSFileName method will assign the directory for the FileName property. Which is wrong but still works good enough…
But if you assign an empty File Name directly to the stream FileName property, then the Stream.SaveFile method will try to show a SaveTo dialog and dialog and scripting threads will lock somehow.
So you either have to assign a correct File Name to the Stream or comment out the DDLScript.SaveToFile(); code.
Very mysteriously, in our case is also working not to clean up the Selected OTP object structure. Perhaps it will turn out that both things are wrongly implemented (the File Name and the cleaning also) and only put together it will show up
Permissions are somehow out of Selected OTP scope. It’s hard coded for what I know…
The sub items are “selected” just like the (root) Model Properties:
function InitGeneratorKeys(Generator, EntityClassName)
{
SelectOTPProperty(SelectOTPClass(Generator.SelectedOTP, EntityClassName),
“Keys”, “Create all Keys”);
Generator.FileName = “C:\Temp\Keys.sql”;
}
You can get the EntityClassName from an Entity object (EntityObj.ClassName) or if you know it, you can use something like PEREntityOR10.
The “Create all Keys” is defined in Generator InitSelectedOTPDefinitions…
Just look at the API documentation and look for Model objects Properties. Then the Properties Captions are the same as in the Selected OTP Tree on the Generator Properties form
Just to let you know that in Beta 3.2.1.12, the CR 47 449 is resolved. - Ability to load OTP selection (for SQL script generation) from XML file from scripts.