Archive for the ‘PeopleCode Tips’ Category

Code to Send Email from Oracle DB (2009-1-15)

Code to Send Email from Oracle DB

DECLARE
v_connection UTL_SMTP.CONNECTION;
BEGIN
v_connection := UTL_SMTP.OPEN_CONNECTION(’mail.company.com’,25);
UTL_SMTP.HELO(v_connection,’mail.company.com’);
UTL_SMTP.MAIL(v_connection,’contact@company.com’);
UTL_SMTP.RCPT(v_connection,’contact@company.com’);
UTL_SMTP.DATA(v_connection,’Testing Hello Mail’);
UTL_SMTP.QUIT(v_connection);
END;

Code to create App Engine Process (Example) (2009-1-15)

See below the example to create process and schedule it as well ….
Function ScheduleNotification(&sRunCntl As string, &nMinuteOffset As number)
&RQST = CreateProcessRequest();
&RQST.ProcessType = “Application Engine”;
&RQST.ProcessName = “MRKCEM_WF_AE”;
&RQST.RunControlID = &sRunCntl;
SQLExec(”SELECT SERVERNAME FROM PS_RB_WF_DEFAULTS”, &WFACTIONSERVER);
If None(&WFACTIONSERVER) Then
[...]

Simple Code to check values in Array (2009-1-15)

– To check the values of array , delete this code after done
&J = 1;
While &LNARRAY.Next(&J)
WinMessage(&LNARRAY [&J]);
End-While;

Error Trapping Application Class (Example) (2009-1-15)

See below the example, which uses application package & class, to trap the error comes in your program. This is reusable in all programs so I found it very useful.
/* Code to write in your code to call Error trap method */
import PKG:CLASS_PKG:*;
Local CLASSname &objName = create CLASSname();
try
—–
catch Exception &ex1
&objName.errorHandler(&ex1, “EOTP_PKG.EOTP_MAIN_PKG.TPMUtil.log”, True);
end-try;

/* Code to [...]

Improve your application classes (2009-1-13)

Simple properties (without get/set) are much more efficient than method calls. Be clear in your design what need to be simple properties, properties with get/set, and methods. Never make something a method that really should be a property.
If all you have is a normal property which is more of an instance variable then avoid [...]