To open a PDM and generate the database creation script in a file using
VBScript, you could use something like this:
Dim PDApp
Set PDApp = CreateObject("PowerDesigner.Application.11.0")
Dim PDM
Set PDM = PDApp.OpenModel("c:\My Documents\MyModel.pdm",
omf_DontOpenView)
If Not (PDM Is Nothing) Then
' Write the create database batch file
Dim ForWriting, system, file, fileName
ForWriting = 2 ' Open a file for writing.
Set system = CreateObject("Scripting.FileSystemObject")
' Write the create database script
fileName = "d:\temp\CreateDatabase.sql"
Set file = system.OpenTextFile(fileName, ForWriting, true)
' Use the GetPreview function to get the database creation
script
file.Write PDM.GetPreview("SQL")
file.Close
End If
In this example, we use the model options saved the PDM.
To modify the options, you could also use VBScript to modify the package
option object.
You could adapt the VBScript to other language (VB, C++, Java, .NET).
--
Matt Creason
Sr. System Consultant
NA PowerDesigner Team