Ȩ > ÀÚ·á½Ç > News Letter
 
Download
News Letter
Site Link
XpertMon ´º½º·¹ÅÍ 4È£
2007/03/22 10:12 9716


¾È³çÇϼ¼¿ä. DB2 ¹× XpertMon »ç¿ëÀÚ ¿©·¯ºÐ!
¢ß ¾ÆÀÌƼ¿¢½ºÆÛÆ®±×·ì DB »ç¾÷ºÎÀÔ´Ï´Ù.
À̹øÁÖ ´º½º·¹ÅÍ´Â Code Objects(COs) ¿¡ ´ëÇØ »ìÆ캸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
COs ¶õ ÇÁ·Î±×·¥ ÄÚµåÀÌÁö¸¸, Trigger³ª Stored Procedure, User Define Function (UDF)ó·³
RDBMS¿¡ ÀúÀåµÇ¾î DB2 °¡ °ü¸®ÇÏ´Â Object¸¦ ¸»ÇÕ´Ï´Ù.


Business rules as code objects
COs ¸¦ »ç¿ëÇÏ°Ô µÇ¸é ÄÚµå Àç»ç¿ë¼ºÀ» ³ôÀÏ ¼ö ÀÖ°í, DB¿¡¼­ °ü¸®Çϱ⠶§¹®¿¡,
ÀÏ°ü¼ºÀ» À¯ÁöÇÒ ¼ö ÀÖÀ¸¸ç, À¯Áöº¸¼ö °ü¸®°¡ Á» ´õ ½¬¿öÁý´Ï´Ù.

¾Æ·¡´Â UDF ¿Í Trigger¸¦ ÀÌ¿ëÇÏ¿© °£´ÜÇÑ Business LogicÀ» ±¸ÇöÇÑ ¿¹Á¦ÀÔ´Ï´Ù.
UDF ´Â Java·Î ±¸ÇöÇÏ¿´½À´Ï´Ù.
ºñÁî´Ï½º ·ÎÁ÷
ABC ¶ó´Â ȸ»ç´Â ÀÚµ¿Â÷ ºÎǰȸ»ç·Î, ´Ã ÀÏÁ¤ÇÑ ¾çÀÇ ÀÚµ¿Â÷ ºÎÇ°À» À¯ÁöÇØ¾ß ÇÕ´Ï´Ù.
¸¸¾à ƯÁ¤ ºÎÇ°ÀÇ Àç°í°¡ ±âÁØÄ¡(15°³)¿¡ ¹Ì´ÞÇÏ°Ô µÇ¸é e-mailÀ» ÅëÇؼ­ ´ã´çÀÚ¿¡°Ô
ºÎÇ°À» Ãß°¡Çϵµ·Ï Å뺸ÇÕ´Ï´Ù.

Å×À̺í ÀÛ¼º ¹× µ¥ÀÌÅÍ Insert

UDF ÀÛ¼º
Java ¿¡¼­ Á¦°øÇÏ´Â Mail API ¸¦ »ç¿ëÇÏ¿© e-mailÀ» º¸³»´Â UDF ¸¦ ÀÛ¼ºÇÕ´Ï´Ù.
http://java.sun.com/products/javamail »çÀÌÆ®¿¡¼­ mail.jar ¿Í activation .jar ÆÄÀÏÀ»
´Ù¿î¹Þ¾Æ CLASSPATH ¿¡ µî·ÏÇÕ´Ï´Ù.
export CLASSPATH=$CLASSPATH:/home/hjlee/UDF/mail.jar:
export CLASSPATH=$CLASSPATH:/home/hjlee/UDF/activation.jar

±×¸®°í ´ÙÀ½°ú °°ÀÌ JAVA ÄÚµå·Î UDF ¸¦ ÀÛ¼ºÇÕ´Ï´Ù.
import java.util.*; import java.math.BigDecimal; import javax.mail.*; import javax.mail.internet.*; public class PARTSupplyUDF{ public static String PARTSupply(int part, String description, String supplier){ try{ // È£½ºÆ® ¸í°ú from e-mail ÁÖ¼Ò¸¦ »óȲ¿¡ ¸Â°Ô ÀÔ·ÂÇÕ´Ï´Ù. String host = "www.iteg.co.kr"; InternetAddress from = new InternetAddress("donna91@empal.com"); InternetAddress sendto = new InternetAddress(supplier); //Retrieve the system properties Properties props = new Properties(); props.put("mail.smtp.protocol","smtp"); props.put("mail.smtp.host",host); props.put("mail.smtp.port","25"); //Create session (triggered fired (tf)) Session tfSession = Session.getInstance(props); //Create the message MimeMessage tfMessage = new MimeMessage(tfSession); tfMessage.setFrom(from); tfMessage.setSubject("ABC ÀÚµ¿Â÷ ºÎǰȸ»ç°¡ ¿À´õÇÑ ³»¿ëÀÔ´Ï´Ù."); String msgText = " Àç°í°¡ ¾ø½À´Ï´Ù. 15°³ ÁÖ¹®ÇÕ´Ï´Ù."; msgText +=" ÆÄÆ® : " + description + " "; msgText +=" ÆÄÆ® ¹øÈ£ :" + part + " "; tfMessage.setText(msgText); tfMessage.addRecipient(Message.RecipientType.TO,sendto); //Send the message javax.mail.Transport.send(tfMessage); } catch(Exception e){ System.out.println("UDF have caught an error: " + e); return "UDF have caught an error: " + e; } return "An Email has been sent to : " + supplier; } // End PARTSupply } // End PARTSupplyUDF
UDF µî·Ï
UDF ¸¦ Java·Î ÀÛ¼ºÇÏ¿´À¸¸é, ÇØ´ç Function À» DB¿¡ µî·ÏÇØ¾ß ÇÕ´Ï´Ù.
µî·Ï¹æ¹ýÀº ´ÙÀ½°ú °°½À´Ï´Ù.
  1. À§¿¡¼­ ÀÛ¼ºÇÑ Class ÆÄÀÏÀ» $instance home directory/sqllib/function ¿¡ copy ÇÕ´Ï´Ù.
  2. ¾Æ·¡¿Í °°ÀÌ create functionÀ» ÀÛ¼ºÇÕ´Ï´Ù.

TRIGGER ÀÛ¼º
Æ®¸®°Å¸¦ ÀÛ¼ºÇÕ´Ï´Ù. stock °ªÀÌ 15ÀÌÇÏ·Î ¶³¾îÁö°Ô µÇ¸é, À§¿¡¼­ ÀÛ¼ºÇÑ UDF¸¦ ÀÌ¿ëÇÏ¿©
´ã´çÀÚ¿¡°Ô ¸ÞÀÏÀ» º¸³»µµ·Ï ÇÕ´Ï´Ù.

°á°ú È®ÀÎ
±×·³ ÀÌÁ¦ UDF¿Í Trigger¸¦ Å×½ºÆ®Çغ¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
´ÙÀ½°ú °°ÀÌ stock À» 15°³ ÀÌÇÏ·Î update ÇÕ´Ï´Ù.

±×¸®Çϸé Trigger °¡ ¹ßµ¿µÇ¾î ¾Æ·¡¿Í °°ÀÌ ¸ÞÀÏÀ» º¸³»°Ô µË´Ï´Ù.



XpertMon for DB2 UDB V2
DB »ç¾÷ºÎ
Tel : 02-2108-1458
Fax : 02-2108-1459
Mobile : 011-896-6545
E-mail : hjlee@iteg.co.kr
URL : http://iteg.co.kr

¸ñ·Ï ±Û¾²±â ¼öÁ¤