24.12.2012 Views

ER/Studio - Embarcadero Technologies Product Documentation

ER/Studio - Embarcadero Technologies Product Documentation

ER/Studio - Embarcadero Technologies Product Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

USING <strong>ER</strong>/STUDIO > WORKING WITH THE DATA DICTIONARY<br />

Create and Edit Libraries<br />

1 In the Data Dictionary, right-click the Libraries folder and then click New Library.<br />

2 Define the library as required and then click OK to complete the editor.<br />

BASIC tab<br />

The following describe options that require additional explanation:<br />

Includes a text editor as well as all the editing and formatting tools that are available on the <strong>ER</strong>/<strong>Studio</strong> Macro<br />

Editor. You can enter library code or you can use the Import button to import it. You can use Visual BASIC and/or<br />

AI to create the code for the library.<br />

Library Example<br />

'This function generates the header for a templated insert<br />

'procedure. Input is entity name that is used to generate<br />

'procedure name. Platform is Oracle.<br />

Function insertprocheader (ent As Entity) As String<br />

Dim result As String<br />

Dim attr As AttributeObj<br />

'add create statement for the procedure with naming convention<br />

result = "CREATE OR REPLACE PROCEDURE P" & ent.TableName & "INS<strong>ER</strong>T" & vbCrLf<br />

result = result & "(" & vbCrLf<br />

'add parameter list for insert statement<br />

'loop in actual sequence order<br />

For i = 1 To ent.Attributes.Count<br />

For Each attr In ent.Attributes<br />

If attr.SequenceNumber = i Then<br />

'make parameter line for column<br />

result = result & "V" & attr.ColumnName & vbTab & vbTab & vbTab<br />

result = result & "IN "<br />

result = result & attr.Datatype & "," & vbCrLf<br />

End If<br />

Next attr<br />

Next i<br />

‘trim last comma of the parameter list<br />

result = Left(result, Len(result) - 3)<br />

'add last closed parantheses<br />

result = result & ")" & vbCrLf<br />

result = result & "AS" & vbCrLf & "BEGIN" & vbCrLf<br />

'return header<br />

insertprocheader = result<br />

End Function<br />

Call to Library Example<br />

This sub main routine demonstrates how to call a library function.<br />

NOTE: The library needs to be added to the reusable trigger or stored procedure.<br />

Sub Main<br />

Dim procstring As String<br />

procstring = insertprocheader(CurrEntity)<br />

'call other library functions for body of procedure<br />

'call other library functions for end of procedure<br />

'check procedure text with a message box<br />

'disable when generating DDL<br />

MsgBox(procstring)<br />

'output procedure string variable to DDL wizard<br />

resultstring = procstring<br />

End Sub<br />

EMBARCAD<strong>ER</strong>O TECHNOLOGIES > <strong>ER</strong>/STUDIO® 8.0.3 US<strong>ER</strong> GUIDE 238

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!