ãã®èšäºã®å¯Ÿè±¡è
ãã®èšäºã¯ãçµéšè±å¯ãªODIïŒOracle Data IntegratorïŒéçºè
ã察象ãšããŠããŸãã BeanShell眮æã®å®è¡é åºã«é¢é£ããææžåãããŠããªãåŽé¢ãããã€ããããŸãã
眮æïŒ ïŒ$ @
èœã¡çãã ãïŒ ïŒ$ @ãã¯eæ²è¡šçŸã§ã¯ãªããç°ãªãã¿ã€ãã®BeanShell眮æã«äœ¿çšãããç¹æ®æåã§ãã ãã®ããã«ããŠããã¹ãŠãäžç·ã«äœ¿çšããããšã決ããéçºè ãããããã«ã€ããŠããã€ãã®åŸ®åŠãªããšãèšãããšãã§ããŸããã§ãããã äžæ¹ãããã¯ã¹ã¯ãªããã§å®è¡ãããã³ãŒãã®æè»ãªçæãæäŸããéåžžã«åŒ·åãªããŒã«ã§ãã
眮æã¯ãã€ã©ãã§å®è¡ãããŸããïŒ ãœãŒã¹æååããšã«ã¿ãŒã²ããã³ãŒãã§ç¹°ãè¿ãããŸããïŒ ç°ãªãã¬ãã«ã®çœ®æããã¹ãã§ããŸããïŒ ãããŠåãïŒ Javaå€æ°ã宣èšããå Žåãã©ãã§ããã䜿çšã§ããŸããïŒ Substitution APIé¢æ°ãåäœããªãå Žåãšåäœããå Žåãããã®ã¯ãªãã§ããïŒã©ã®æ©èœãé©çšå¯èœãªçœ®æã¬ãã«ã§ææžåãããŠããªãã®ã§ããïŒã ãªã©ãªã©ã ãããã®äžååã«ææžåããã埮åŠãã«ã€ããŠãäžé£ã®èšäºãåãäžããããŠããŸãã ãããŠãããã圌ãã®æåã§ãã
ã«ãã¯ã¢ããã«å ±éããã®ã¯ã BeanShellã¹ã¯ãªãããã«ãã¯ã¢ããå ã§å®è¡ãããããšã§ãã 眮æåŠçã¯ãJSPãŸãã¯PHPã®è§£æãé£æ³ãããŸãã åæ§ã«ãççž®æ§æãšå®å šæ§æã®2ã€ã®çœ®ææ§æãåºå¥ãããŸãã çç¥åœ¢ã§ã¯ã眮æã«ã¯ãå®è¡æã«ãã®çœ®æã眮ãæããçµæãæã€åŒã®ã¿ãå«ãŸããŸãã
<%=odiRef.getSysDate("yyyy-MM-DD HH:mm:ss.SSS")%>
å®å šãªæ§æã«ã¯ã out.printïŒïŒã䜿çšããŠäœãããå°å·ãã§ããããŸãã¯ãŸã£ããå°å·ããªãããä»ã®æçšãªäœæ¥ãéãã«å®è¡ã§ããå®å šãªBeanShellã³ãŒããå«ãŸããŠããŸãã åŸè ã®å Žåã眮æãå®è¡ããåŸããã¬ãŒã¹ãæ®ããã«ã³ãŒãããåçŽã«åé€ãããŸãã
<%out.print(odiRef.getSysDate("yyyy-MM-DD HH:mm:ss.SSS"));%>
åç §ã¬ãã«
ïŒ ã¬ãã«
<ïŒ ...ïŒ >ã®åœ¢åŒã®çœ®æã¯ãã»ãã·ã§ã³ãéå§ãããã¹ãã§ç©ç眮æãå®è¡ãããåã§ãã£ãŠããã»ãã·ã§ã³ã®éå§æã«çŽã¡ã«å®è¡ãããŸãã ã€ãŸãããã¶ã€ããŒããODIã»ãã·ã§ã³ãéå§ãããšãã¯ãŒã¯ã¹ããŒã·ã§ã³ã§ïŒ 眮æãå®è¡ããã眮æã¹ã¯ãªããããããšãã°ãã¡ã€ã«ã·ã¹ãã ã«ã¢ã¯ã»ã¹ããããšã決å®ããå ŽåïŒããã³Beanshellã«ã¯ããã¹ãŠã®Javaæ©èœã«å ããŠãç¬èªã®ãã€ãã£ãæ©èœããããŸãïŒ ïŒãããŒã«ã«ãã£ã¹ã¯ã衚瀺ãããŸãã ãã§ã«ã¢ã»ã³ãã«ãããODIã¹ã¯ãªãããèµ·åããããšã-InvokeStartScenæäœãåŒã³åºãããã¹ã±ãžã¥ãŒã©ããèµ·åããå Žåãèµ·åãéå§ããã¯ã©ã€ã¢ã³ãã¯ODIãšãŒãžã§ã³ãèªäœã§ãïŒïŒ 眮æãå®è¡ããç©ççãªå Žæã¯ODIãšãŒãžã§ã³ããµãŒããŒã§ãã
ïŒ çœ®æã®å®è¡äžã«äŸå€ãçºçããå Žåããã©ãŒã«ã¯çºçããŸããã ãšã©ãŒã®ã¹ã¿ãã¯å šäœãåºåã§é€å€ããã眮æã®çµæã«ãªããŸãã ãã®çµæã¯ãœãŒã¹ã³ãŒãïŒæ¢ã«ç¡å¹ïŒã«ãªãã次ã®ã¬ãã«ã§è§£éãè©Šè¡ãããããã§ã»ãã·ã§ã³ãã¯ã©ãã·ã¥ããŸãã
ãã®çœ®æã¯ãå€æ°ã®èšå®ããã³å€æ°ã®è©äŸ¡ã¹ãããå ã§ã¯æ©èœããŸããã ã€ãŸããããã§ã¯éåžžã®ããã¹ããšããŠèªèããããããªãæ¹æ³ã§ãåŠçãããŸããã
ãã®ã¬ãã«ããã¯ããœãŒã¹æ¥ç¶ãŸãã¯ã¿ãŒã²ããæ¥ç¶ã®ãããã«ãæ¥ç¶ã§ãããäœæ¥ãªããžããªã«ã®ã¿æ¥ç¶ã§ããŸãã ããªãã¡ odiRef.getJDBCConnectionïŒãWORKREPãïŒã¯ãã§ã«äœ¿çšå¯èœã§ãããä»ã®åŒæ°ãæã€ãã®é¢æ°ãgetJDBCConnectionFromLSchemaïŒïŒãæ©èœããŸããã æ¥ç¶ããŸã ååšããªããããã»ãã·ã§ã³ã®äœæ¥ã¯ãŸã éå§ãããŠããŸããã
ã¬ãã«ïŒ
ãã®ãããã¹ã¯ãªããã¯ãã§ã«ãšãŒãžã§ã³ãå ã«ãããå®è¡ãéå§ããŠããŸãã ã»ãã·ã§ã³ãäœæãããŸããã æåã®ã¹ãããïŒã¹ãããïŒã§ã¯ãã³ãŒãã®æçµçãªåœ¢æãè¡ãããŸãããšã³ããªãSNP_STEP_LOGã«è¡šç€ºããããã®ã¹ãããã®ãã¹ãŠã®ã¿ã¹ã¯ã®æçµçãªã³ãŒããçæãããŸãã ããã¯ã眮æ<ïŒ...ïŒ>ãå®è¡ãããå Žæã§ãã æ£åžžã«å®è¡ãããåŸïŒãŸãã¯çœ®æããªãå ŽåïŒããšã³ããªãSNP_SESS_TASK_LOGã«äœæãããããã«çµæãé 眮ãããŸãïŒæçµã³ãŒãïŒã 解éäžã«ãšã©ãŒãçºçããå Žåã SNP_SESS_TASK_LOGã®ãšã³ããªã¯äœæãããããšã©ãŒã¡ãã»ãŒãžã¯SNP_STEP_LOGã§äžã§æ€çŽ¢ããå¿ èŠããããŸãã ã¹ãããå šäœãæºåããããšãããã«å®è¡ãéå§ãããŸãã TheïŒçœ®æã€ã³ã¿ãŒããªã¿ãŒã¯ã次ã®ã¹ãããã®åã«äœæ¥ãåéããŸãã
ïŒ-å€æ°ã®èšå®æé ãšå€æ°ã®è©äŸ¡æé ã§ããåæ§ã«çœ®æã¯ç¡èŠãããŸãã ãã®çœ®æã§ã¯ããœãŒã¹ããã³ã¿ãŒã²ããæ¥ç¶ã䜿çšããodiRef.getJDBCConnectioné¢æ°ã§ååŸããããšããã§ã«å¯èœã§ãã ããã¯ãæè»ãªã³ãŒãçæã®ããã«ãããŒãã«ã®ã©ããã«ããããŒã¿ã䜿çšã§ããããšãæå³ããŸãã
ã¬ãã«$
ããã¯ã¿ã¹ã¯ãå®äºããçŽåã«å®è¡ãããç¹å¥ãªã¬ãã«ã§ããããã®çœ®æã®çµæã¯SNP_SESS_TASK_LOGã®ã¬ã³ãŒããæŽæ°ããããã«äœ¿çšãããŸãã ããã«ã$眮æãäœããåºåããODIå€æ°ã眮æå ã§äœ¿çšãããå Žåããã°ã§ã¯ãéåžžã®ããã«ååã§ã¯ãªãå€æ°ã®å€ã衚瀺ãããŸãã ã€ãŸãããã®çœ®æãå¹æçã«äœ¿çšããŠããªãã¬ãŒã¿ãã°ã®å€æ°ã®å€ã確èªã§ããŸãã
ããã«ã$眮æã¯ã odiRef.setTaskNameïŒïŒé¢æ°ãã³ãŒã«ã§ããå¯äžã®å Žæã§ãããã®é¢æ°ã¯äœãåºåããŸãããããã°å ã®ã¿ã¹ã¯ã®ååãå€æŽããŸãã å®éããããã¯$眮æãæçšãªã¢ããªã±ãŒã·ã§ã³ã®2ã€ã®é åã®ã¿ã§ãã
ãŸãããã®çœ®æã¯ãå€æ°ã®èšå®ããã³å€æ°ã®è©äŸ¡ã¹ãããã§ãæ©èœããŸããã
ã¬ãã«@
æçµçãªã¿ã¹ã¯ã³ãŒãã¯ãæçµçãªãã®ã§ã¯ãããŸããã æçµã³ãŒãã®è§£éãšå®è¡ã¯ããã¯ãããžãŒã«å¯Ÿå¿ããèšèªã§å®è¡ãããŸãããä»»æã®ãã¯ãããžãŒã®ã³ãŒãã«Java BeanShellã³ãŒãã®@眮æãå«ããããšãã§ããŸãã åœç¶ã眮æãæåã«å®è¡ãããŸãã 圌女ãäœããå°å·ããå Žåãå®è¡åã«ã¿ã¹ã¯ã®ãæçµãã³ãŒããããã«å€æŽããŸãã
@眮æã¯ãå€æ°ã®èšå®ã¹ãããã§é©çšã§ããŸãã ãããã£ãŠãJavaåŒã®çµæãODIå€æ°ã«ç°¡åã«å²ãåœãŠãããšãã§ããŸãã å€æ°ã®è©äŸ¡ã§ã¯ããŸã äœãã§ããŸããã 眮æäžã«äŸå€ãçºçããå Žåãã»ãã·ã§ã³ã¯çŸåšã®ã¹ãããã«åé¡ãããŸãã
ãœãŒã¹ãŸãã¯ã¿ãŒã²ãããæåã¯èª°ã§ããïŒ
ODIã®ã»ãã·ã§ã³ã¯ãã¹ãŠã¹ãããã§æ§æãããåã¹ãããã«ã¯1ã€ä»¥äžã®ã¿ã¹ã¯ããããåã¿ã¹ã¯ã«ã¯åžžã«2ã€ã®è©ïŒãœãŒã¹ãšã¿ãŒã²ããïŒããããŸãã ããšãã°ããªãã¬ãã·ã¥ãŸãã¯ODIå€æ°ã®ã»ããã¯ã空ã®æ¬äœãœãŒã¹ã䜿çšããå Žåãšåãã¿ã¹ã¯ã§ãã 代æ¿ã¯äž¡æ¹ã®è©ã«ããå¯èœæ§ãããã®ã§ãã©ã¡ããããæ©ãå®è¡ãããããç¥ãããšã¯èå³æ·±ããæã«ã¯éèŠã§ãã ãªããªããæåã«javaå€æ°ã宣èšããŠå²ãåœãŠãŠãã䜿çšããããšãéèŠã ããã§ãã
é©ããããšã«ãïŒ çœ®æãïŒ ããã³$ã¯ãæåã«ã¿ãŒã²ããã¬ãã¬ããžã«å¯ŸããŠå®è¡ããã次ã«ãœãŒã¹ã«å¯ŸããŠå®è¡ãããŸãã ãããã@眮æã¯éã§ãã
ãã®ããããã£ãç¥ã£ãŠããã°ãå€æ°ãé¢æ°ãã¹ã¯ãªãããªããžã§ã¯ããããã³éåžžã®BeanShellã¯ã©ã¹ãæ£ããåæåããŠãããããããæ£ãã䜿çšã§ããŸãã
@眮æã®ç¹°ãè¿ã
ä»ã®ã¬ãã«ã§ã¯ããã¹ãŠãç°¡åã§ãã æåã«ã¿ãŒã²ããã解éããã次ã«ãœãŒã¹ã解éãããŸãã ã¬ãã«@ã§ã¯ããã¹ãŠãç°ãªããå€ãã®èŠå ã«äŸåããŸãã
prepareStatementããµããŒããããœãŒã¹ããã³ã¿ãŒã²ããã®è©ã§Oracleãã¯ãããžãŒãéžæãããšããŸãããã ãŸããäž¡æ¹ã®è©ã«@眮æããããŸãã ãã®ç¶æ³ã§ã¯ãå¶éãé©çšãããŸãããœãŒã¹ã§äœ¿çšã§ããã®ã¯selectã®ã¿ã§ãã äŸãã°ããã¡ãã¡ã§pl / sql-blockãå®è¡ããããšã¯äžå¯èœã§ãã
ãœãŒã¹ã·ã§ã«ããŒã«ç©ºã§ãªãã³ãŒããããå Žåã¯ãæåã«å®è¡ãããŸãã ãããã£ãŠããœãŒã¹ã³ãŒããå®è¡ããåã«ããœãŒã¹ã³ãŒãã§çœ®æã1åå®è¡ããŸãã
ãœãŒã¹ã¯ãODIããã£ããããå¿ èŠãããResultSetãæäŸãããã§ããããšã«ã¿ãŒã²ããã¬ãã¬ããžã®å®è¡ãè©Šã¿ãŸãã ãœãŒã¹ãã£ãŒã«ãã«ã¢ã¯ã»ã¹ããã«ã¯å€ãã®æ¹æ³ããããŸãã ãšã³ããªFIELD_NAMEãŸãã¯ïŒFIELD_NAMEã䜿çšã§ããŸãã ã¿ãŒã²ãããã¯ãããžãã©ã€ããŒãprepareStatementæäœããµããŒããïŒããã¯ãã¹ãŠã®JDBCãã©ã€ããŒã§äžè¬çã§ãïŒããã£ãŒã«ãã«FIELD_NAMEè¡šèšã®ã¿ã䜿çšãããå ŽåãODIã¯@眮æãšprepareStatementã1åå®è¡ããŸãã ãããŠããã§ããããšã«å€æ°ãã€ã³ãã£ã³ã°ãšã¹ããŒãã¡ã³ãå®è¡ã®ã¿ãå®è¡ããŸãã
å°ãªããšã1åãïŒãä»ããåŒã³åºãããã£ãŒã«ãã«äœ¿çšãããïŒåçŽãªããã¹ã眮æãæå³ããïŒå ŽåããŸãã¯ãã©ã€ããŒãprepareStatementããµããŒãããªãå Žåãã¿ãŒã²ããæŒç®åã®åœ¢æã¯åå埩ã§ç¹å¥ãªïŒåã ã®ïŒããã@眮æãäœåºŠãå®è¡ãããŸãã
äŸãèããŠã¿ãŸãããïŒ
ãœãŒã¹ïŒ
<@long i=0L;@> select f1, f2 from table /* 10 */
ã¿ãŒã²ããïŒãªãã·ã§ã³1ïŒïŒ
begin stored_Procedure(<@=++i@>, :f1, :f2); /* = 1, 1 prepareStatement */ end;
ã¿ãŒã²ããïŒãªãã·ã§ã³2ïŒïŒ
begin stored_Procedure(<@=++i@>, #f1, #f2); /* = 1, 2, 3..... , , i 10, .. */ end;
æåã®ããªã¢ã³ãã§ã¯ãprepareStatementã®çºçæã«@眮æã1åå®è¡ãããŸãã ãããŠ2çªç®ã«ãåãã§ããã¯æ°ããæŒç®åããã¹ãã®åœ¢æãš@眮æã®æ°ããå®è¡ãåŒãèµ·ãããŸãã
ã¿ãŒã²ãããã¯ãããžãŒãprepareStatementãå®è¡ããæ©èœãæäŸããªãå ŽåïŒããšãã°ãOdiToolsïŒãã³ãã³ãä»ããŠãœãŒã¹ãã£ãŒã«ãã«ã¢ã¯ã»ã¹ããããšã¯äžå¯èœããïŒãšå€ãããŸããã
å°æ¥ã®èšäºã§ã¯ãSubstitution APIã®çœ®æãšäœ¿çšã«é¢é£ããä»ã®åé¡ã«ã€ããŠæ€èšããŸãã ç¹ã«ã 次åã¯åãã¬ãã«ãšç°ãªãã¬ãã«ã®é åã®ååž°çãªè§£éãå«ããã¹ãã«ã€ããŠèª¬æããŸãã å€ãã®äºæããªãçºèŠãããªããåŸ ã£ãŠãããããªãã¯äœåºŠãå«ã¶ã§ãããïŒããããããããã®ããã«åãçç±ã§ãïŒã