InterBase/FireBird¿Í ADO
Á¶È¸ : 525 À̸§ : ¾Æ¹«³ª
E-mail :
20 / InterBase/FireBird¿Í ADO
ÀÛ¼ºÀÚ : ¹ÚÁöÈÆ.ÀÓÇÁ (cbuilder) ÀÐÀ½ : 1566 2006-11-18 ¿ÀÈÄ 7:56:15



¾Æ·¡ÀÇ ÁÖ¼Ò¿¡ ÀÖ´Â ±ÛÀ» ¹ø¿ªÇÑ °ÍÀÔ´Ï´Ù.
http://www.bdcsoftware.com/blog/entry/4/Interbase_and_ADO_tutorial

--------------------------------------------------------------------------------

SQL¼­¹ö³ª ¾×¼¼½º µ¥ÀÌÅͺ£À̽º ´ë½Å ¾µ ¸¸ÇÑ ¿ÀǼҽº ¼Ö·ç¼ÇÀÌ ¾ø´ÂÁö ÇѹøÂëÀº ±Ã±ÝÇϽŠÀûÀÌ ÀÖÀ» °Ì´Ï´Ù.
Àúµµ ±×·± ÀûÀÌ ÀÖ¾ú°í, ÀÎÅͺ£À̽º¸¦ ã¾Æ³Â½À´Ï´Ù. ÀÎÅͺ£À̽º´Â º¼·£µå¿¡¼­ ³ª¿Â Ŭ¶óÀ̾ðÆ®/¼­¹ö µ¥ÀÌÅͺ£À̽ºÀÌ°í, ¿ÀǼҽº ±â¹ÝÀÔ´Ï´Ù. ÀÎÅͺ£À̽º´Â À©µµ¿ì, ¸®´ª½º, ±×¸®°í ¿©·¯ ´Ù¸¥ À¯´Ð½º °è¿­ OS¿¡¼­ µ¿ÀÛÇÕ´Ï´Ù. ÀÎÅͺ£À̽º´Â ¸Å¿ì ÀûÀº ¸Þ¸ð¸®¸¦ »ç¿ëÇÏ°í, »ó´çÈ÷ ºü¸£±â±îÁö ÇÕ´Ï´Ù. ±×¸®°í ´ë¿ë·® µ¥ÀÌÅͺ£À̽º ÆÄÀϵµ Áö¿øÇÕ´Ï´Ù. (2GB ÀÌ»óÀ» ¸»ÇÏ´Â °Ì´Ï´Ù. 300GB ÀÌ»óÀÇ µ¥ÀÌÅͺ£À̽º¸¦ ¿î¿µÁßÀÎ »ç¶÷µµ ¾Ë°í ÀÖ½À´Ï´Ù) ¾î·µç, ÀÌ °­Á¿¡¼­´Â ¿©·¯ºÐÀÌ ÀÎÅͺ£À̽º¸¦ »ç¿ëÇÏ´Â µ¥ ÇÊ¿äÇÑ ¿©·¯ ¹®Á¦µé°ú Åøµé¿¡ ´ëÇØ ¼³¸íÇÏ°Ú½À´Ï´Ù.

¸ÕÀú ÀÎÅͺ£À̽ºÀÇ ÀåÁ¡¿¡ ´ëÇØ ¼³¸íÇÏ°Ú½À´Ï´Ù.
1. ¿ÀÇ ¼Ò½ºÀÌ´Ù
2. ºü¸£´Ù
3. Å©±â°¡ ÀÛ´Ù
4. ¹èÆ÷°¡ ¸Å¿ì ÆíÇÏ´Ù (¿ÍÀÌÁî, ÀνºÅç½Çµå¸¦ À§ÇÑ ½ºÅ©¸³Æ®°¡ ÀÖÀ½)
5. ADO¿Í »ç¿ë °¡´É
6. ODBC¿Í »ç¿ë °¡´É
7. ´ë´ÜÇÑ Æ®·£Àè¼Ç °ü¸® (Àбâ ÀÛ¾÷ÀÌ ¾²±â ÀÛ¾÷À» ºí·ÎÅ·ÇÏÁö ¾ÊÀ¸¸ç ¹Ý´ëµµ ¸¶Âù°¡ÁöÀÓ)
8. ¿©·¯ Ç÷§ÆûÀ» Áö¿ø (¸®´ª½º/À¯´Ð½º)
9. BLOB Çʵå Áö¿ø (À̹ÌÁö, ¸Þ¸ð ÇÊµå µî)
10. ¹è¿­ Áö¿ø (¹è¿­À» °¢°¢ÀÇ Çʵ忡 ÀúÀåÇÒ ¼ö ÀÖÀ½)

ÀÎÅͺ£À̽º¸¦ ½ÃÀÛÇÏ·Á¸é, ¼­¹ö¿Í Ŭ¶óÀ̾ðÆ® ¼ÒÇÁÆ®¿þ¾î°¡ ÇÊ¿äÇÕ´Ï´Ù. ¿ø·¡ÀÇ ¿ÀǼҽº ¹öÀüÀÇ ¼Ò½º¿Í ¹ÙÀ̳ʸ®´Â º¼·£µå¿¡¼­ ´Ù¿î·Îµå °¡´ÉÇÕ´Ï´Ù.
http://www.borland.com/devsupport/interbase/opensource/

¼öÁ¤µÈ ¹öÀüÀÎ ÆÄÀ̾î¹öµå´Â ´ÙÀ½ ÁÖ¼Ò¿¡¼­ ´Ù¿î·ÎµåÇÒ ¼ö ÀÖ½À´Ï´Ù.
http://www.ibphoenix.com/ibp_download.html

¼­¹ö ¹× Ŭ¶óÀ̾ðÆ® ¹ÙÀ̳ʸ®¸¦ ´Ù¿î·ÎµåÇÏ°í ¼³Ä¡ÇÕ´Ï´Ù. ÀÎÅͺ£À̽º ¼­¹ö¿¡´Â ODBC µå¶óÀ̹ö°¡ Æ÷ÇԵǾî ÀÖÁö¸¸, Àú´Â ODBC¸¦ ½È¾îÇÏ°í º¸ÅëÀÇ ÀÛ¾÷¿¡´Â ADO/OleDB¸¦ ÀÌ¿ëÇÕ´Ï´Ù. ±×·¡¼­ ÀÎÅͺ£À̽º¸¦ À§ÇÑ OleDB µå¶óÀ̹ö¸¦ ã¾ÆºÃ½À´Ï´Ù. ´ÙÇàÈ÷µµ ¿©·¯ Á¾·ù°¡ ÀÖ´õ±º¿ä. ¾Æ·¡ »çÀÌÆ®¿¡¼­ ´Ù¿î·Îµå °¡´ÉÇÑ »çÀÌÆ®·ÎÀÇ ¸µÅ©µéÀ» º¼ ¼ö ÀÖ½À´Ï´Ù.
http://www.interbase2000.org/tools_conn.htm

Àú´Â http://www.lcpi.lipetsk.ru/prog/eng/index.html ¿¡¼­ ´Ù¿î¹ÞÀº IBProvider¸¦ ¼±ÅÃÇß½À´Ï´Ù. ÇÁ·Î¹ÙÀÌ´õ¸¦ ADO¿Í »ç¿ëÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁÖ´Â ¸î°¡Áö VB ¿¹Á¦°¡ Æ÷ÇԵǾî ÀÖ¾ú±â ¶§¹®ÀÔ´Ï´Ù. ¿©·¯ºÐÀÌ ´Ù¿î·ÎµåÇÒ ¼ö ÀÖ´Â ¹öÀüÀº 30ÀÏ Æò°¡ÆÇÀÔ´Ï´Ù. ¿ÏÀüÈ÷ ¹«·áÀÎ OleDB ÇÁ·Î¹ÙÀÌ´õ¸¦ ¿øÇÑ´Ù¸é Http://www.oledb.net/?Page=FAQ ¸¦ Âü°íÇϼ¼¿ä. ÇÏÁö¸¸, Á¦°¡ ¸¸µç ¸ðµç »ùÇà ÄÚµå´Â IBProvider¿¡¼­¸¸ Å×½ºÆ®Çغôٴ °ÍÀ» ¸»¾¸µå¸³´Ï´Ù.

ÀÏ´Ü ¸ðµç ÆÄÀÏÀ» ´Ù¿î·ÎµåÇÏ°í ¼³Ä¡Çß´Ù¸é, ÀÌÁ¦ °³¹ßÀ» ½ÃÀÛÇÒ Áغñ°¡ µÈ °ÍÀÔ´Ï´Ù. ÀÎÅͺ£À̽º¿¡´Â employee.gdb ¶ó´Â »ùÇà µ¥ÀÌÅͺ£À̽º°¡ Æ÷ÇԵǾî ÀÖ½À´Ï´Ù. ¿ì¸®´Â ÀÌ µ¥ÀÌÅͺ£À̽º¸¦ ¿¹Á¦·Î »ç¿ëÇÒ °ÍÀÔ´Ï´Ù. (µðÆúÆ® À§Ä¡´Â C:\Program Files\Borland\InterBase\examples\Database ÀÔ´Ï´Ù). ¾î·µç, ±âÃʺÎÅÍ ½ÃÀÛÇغ¾½Ã´Ù.

ÀÎÅͺ£À̽º¿¡ ¿¬°áÇϱâ
µ¥ÀÌÅͺ£À̽º·ÎÀÇ ¿¬°áÀ» ¸Î¾îº¾½Ã´Ù. ¿¹Á¦ ¿¬°á ÄÚµå´Â ´ÙÀ½°ú °°½À´Ï´Ù.

Dim adoConn As New ADODB.Connection

adoConn.ConnectionString = "provider=LCPI.IBProvider;data source=localhost:C:Interbase DBsEmployee.gdb;ctype=win1251;user id=SYSDBA;password=masterkey"

adoConn.Open

Dim adoConn As New ADODB.Connection

adoConn.ConnectionString = "provider=LCPI.IBProvider;data source=localhost:C:Interbase DBsEmployee.gdb;ctype=win1251;user id=SYSDBA;password=masterkey"

adoConn.Open

¸î°¡Áö °í·ÁÇØ¾ß ÇÒ °ÍµéÀÌ ÀÖ½À´Ï´Ù.
µðÆúÆ® À¯Àú ³×ÀÓ°ú Æнº¿öµå(SQL¼­¹ö¿¡¼­ÀÇ SAó·³)´Â °¢°¢ SYSDBA¿Í masterkeyÀÔ´Ï´Ù(´ë¼Ò¹®ÀÚ ±¸º°). 'data source' ÆĶó¹ÌÅÍ´Â 'IPÁÖ¼Ò:¼­¹ö»óÀÇÆÄÀÏÀ§Ä¡' °ú °°Àº Çü½ÄÀÔ´Ï´Ù. ¿©·¯ºÐÀÇ °³¹ß PC¿¡ ¼­¹ö¸¦ ¼³Ä¡Çß´Ù¸é localhost³ª ¿©·¯ºÐÀÇ IP¸¦ ¾²¸é µË´Ï´Ù. ¿ø°ÝÀÇ ¼­¹ö¿¡ ¼³Ä¡Çß´Ù¸é ±× ¼­¹öÀÇ IP ÁÖ¼Ò¸¦ ¾²¸é µË´Ï´Ù. ÆÄÀÏ À§Ä¡ ºÎºÐÀº Á¶±Ý º¹ÀâÇѵ¥, ¼­¹öÀÇ ·ÎÄà À§Ä¡À̸ç UNC Æнº¸¦ ¾²¸é ¾ÈµË´Ï´Ù.

ÀÏ´Ü ¿¬°áÀÌ ¸Î¾îÁ³À¸¸é, ÀÌÁ¦ µ¥ÀÌÅͺ£À̽º ÀÛ¾÷À» ½ÃÀÛÇÒ ¼ö ÀÖ½À´Ï´Ù.

ÀÎÅͺ£À̽º µ¥ÀÌÅͺ£À̽º ÀÛ¾÷Çϱâ
¹«¾ùº¸´Ù ¸ÕÀú, ÀÎÅͺ£À̽º¿Í ÀÛ¾÷ÇÏ´Â °ÍÀº SQL¼­¹ö³ª ¾×¼¼½º¸¦ »ç¿ëÇÏ´Â °Í¸¸Å­ ½±½À´Ï´Ù. ÇÏÁö¸¸ ¸î°¡Áö °í·ÁÇØ¾ß ÇÏ´Â »çÇ×µéÀÌ ÀÖ½À´Ï´Ù.

ù¹ø°·Î, ÀÎÅͺ£À̽º¿¡´Â ´ÙÀ̾ó·ºÆ®(dialect)¶ó´Â °³³äÀÌ ÀÖ½À´Ï´Ù. ÀÌ°ÍÀº ¿©·¯ºÐÀÌ µ¥ÀÌÅͺ£À̽º¿¡ ¸í·ÉÀ» º¸³¾ ¶§ÀÇ SQL ¹®¹ýÀ» ÀǹÌÇÕ´Ï´Ù. ÀÎÅͺ£À̽º 6.0¿¡¼­´Â Dialect 1(ÀÌÀü¹öÀü ȣȯ¿ë)¿Í Dialect 3¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. »ùÇà µ¥ÀÌÅͺ£À̽º´Â Dialect 1À¸·Î ÀÛ¼ºµÇ¾î ÀÖ½À´Ï´Ù. ¸¸¾à Dialect 3¸¦ »ç¿ëÇÏ·Á°í ÇÑ´Ù¸é(Àúó·³), ¸î°¡Áö ÀÌ»óÇÑ µ¿ÀÛÀ» º¸°Ô µÉ °Ì´Ï´Ù. ¿©·¯ºÐÀÇ µ¥ÀÌÅͺ£À̽º¿¡ ¼Ò¹®ÀÚ Å×À̺í°ú Çʵå À̸§ÀÌ ÀÖ´Â °æ¿ì, ¼Ò¹®ÀÚ À̸§µéÀ» ½Öµû¿ÈÇ¥·Î °¨½Î¾ß ÇÕ´Ï´Ù. ¿¹¸¦ µé¾î Select "CompanyName", "Address" from "tblCustomers" ÀÌ·¸°Ô ¸»ÀÌÁÒ. ¸»ÇÒ ÇÊ¿äµµ ¾øÀÌ ÀÌ ¹®Á¦´Â VB °³¹ßÀڵ鿡°Ô´Â È¥¶õÀ» °¡Á®¿É´Ï´Ù. ÇÑ°¡Áö ÇÇÇØ°¡´Â ¹æ¹ýÀº Å×À̺í°ú ÇʵåÀÇ À̸§À¸·Î ´ë¹®ÀÚ¸¦ »ç¿ëÇÏ´Â °Ì´Ï´Ù. (ÇÏÁö¸¸ Á¦°Ô ¿Ö ±×·±Áö¸¦ ¹¯Áö´Â ¸»¾ÆÁÖ¼¼¿ä) ¿¹¸¦ µé¸é, SELECT COMPAN_YNAME, ADDRESS FROM TBLCUSTOMERS ÀÌ·¸°Ô ¸»ÀÌÁÒ.

Á¦°¡ ¹ß°ßÇÑ ´Ù¸¥ ¹®Á¦´Â, Ä¿¸Çµå ŸÀÔÀ¸·Î adCmdStoredProcÀ» ¾µ ¼ö ¾ø´Ù´Â °ÍÀÔ´Ï´Ù. ÀÌ ¹®Á¦¸¦ ÇÇÇÏ·Á¸é adCmdText¸¦ ¾²¸é µË´Ï´Ù. ÀÌÈÄ¿¡ ´õ ÀÚ¼¼È÷ ¼³¸íµå¸®°Ú½À´Ï´Ù.

³×, ÀÌÁ¦, ¿ì¸® µ¥ÀÌÅͺ£À̽º¿¡ µ¥ÀÌÅ͸¦ ³Ö°í »©·Á¸é ¾î¶»°Ô ÇÒ±î¿ä? SQL ¹®À» ½ÇÇàÇϱâ À§ÇØ ¿©·¯ºÐÀÌ ÀÏ»óÀûÀ¸·Î »ç¿ëÇÏ´ø ·¹ÄÚµå¼Â °´Ã¼¸¦ »ç¿ëÇϰųª ½ºÅä¾îµå ÇÁ·Î½ÃÀú¸¦ ÀÌ¿ëÇÒ ¼öµµ ÀÖ½À´Ï´Ù.

¾Æ·¡¿¡ °£´ÜÇÑ ¼¿·ºÆ® ¹®À» ¿¹·Î º¸¿©µå¸³´Ï´Ù.

Dim rst As New Recordset

rst.Source = "SELECT CUSTOMER.CONTACT_FIRST, " & _
"CUSTOMER.CONTACT_LAST, CUSTOMER.COUNTRY " & _
"FROM CUSTOMER"

rst.ActiveConnection = adoConn
adoConn.BeginTrans
rst.Open
adoConn.CommitTrans

Dim rst As New Recordset

rst.Source = "SELECT CUSTOMER.CONTACT_FIRST, " & _
"CUSTOMER.CONTACT_LAST, CUSTOMER.COUNTRY " & _
"FROM CUSTOMER"

rst.ActiveConnection = adoConn
adoConn.BeginTrans
rst.Open
adoConn.CommitTrans


±×¸®°í ¾Æ·¡´Â °£´ÜÇÑ ½ºÅä¾îµå ÇÁ·Î½ÃÀú ½ÇÇà ¿¹ÀÔ´Ï´Ù.

Dim rst As New Recordset
Dim cmd As New ADODB.Command

adoConn.Open

With cmd
.ActiveConnection = adoConn
.CommandText = "Select * FROM DEPT_BUDGET (100)"
End With

adoConn.BeginTrans
Set rst = cmd.Execute
adoConn.CommitTrans

Dim rst As New Recordset
Dim cmd As New ADODB.Command

adoConn.Open

With cmd
.ActiveConnection = adoConn
.CommandText = "Select * FROM DEPT_BUDGET (100)"
End With

adoConn.BeginTrans
Set rst = cmd.Execute
adoConn.CommitTrans

½ºÅä¾îµå ÇÁ·Î½ÃÀú°¡ ·Î¿ìµéÀ» ¸®ÅÏÇÏ´Â °æ¿ì, SELECT * FROM ÇÁ·Î½ÃÀúÀ̸§ ÀÌ·± ½ÄÀ¸·Î È£ÃâÇÏ¸é µË´Ï´Ù. ÇÁ·Î½ÃÀú°¡ ·Î¿ì¸¦ ¸®ÅÏÇÏÁö ¾ÊÀ¸¸é EXECUTE ÇÁ·Î½ÃÀúÀ̸§ ÀÌ·¸°Ô È£ÃâÇÏ¸é µË´Ï´Ù.

ÇÁ·Î½ÃÀú¿¡ ÆĶó¹ÌÅ͸¦ ³Ñ°ÜÁÖ°í µ¹·Á¹Þ´Â ¹æ¹ýµµ Á» ƯÀÌÇÕ´Ï´Ù. 3°³ÀÇ ÆĶó¹ÌÅ͸¦ ¹Þ´Â Àμ­Æ® ½ºÅä¾îµå ÇÁ·Î½ÃÀúÀÇ °æ¿ì, ÆĶó¹ÌÅ͵éÀ» Àü´ÞÇÏ·Á¸é ÀζóÀÎ ¹®¹ýÀ» »ç¿ëÇØ¾ß ÇÕ´Ï´Ù. ¿¹¸¦ µé¸é, 'execute procedure PROC_INSERT_TBLCUSTOMERS (½°Ç¥·Î ³ª´µ¾îÁø ÆĶó¹ÌÅÍ ¸ñ·Ï)' ¾Æ´Ï¸é ´ÙÀ½°ú °°ÀÌ ÇÒ ¼öµµ ÀÖ½À´Ï´Ù.

With cmd
.ActiveConnection = adoConn
.CommandText = " execute procedure PROC_INSERT_TBLCUSTOMERS (?,?,?)"
End With

adoConn.BeginTrans
cmd(0) = parameter value
cmd(1) = parameter value
cmd(2) = parameter value
cmd.Execute
adoConn.CommitTrans

With cmd
.ActiveConnection = adoConn
.CommandText = " execute procedure PROC_INSERT_TBLCUSTOMERS (?,?,?)"
End With

adoConn.BeginTrans
cmd(0) = parameter value
cmd(1) = parameter value
cmd(2) = parameter value
cmd.Execute
adoConn.CommitTrans

¾î·µç, ÀÌ Á¤µµ°¡ ±âÃÊÀÔ´Ï´Ù. ¿©·¯ºÐÀÌ ÀÎÅͺ£À̽º¿¡ °ü½ÉÀ» °¡Á®ÁÖ¸é, À̹ÌÁö, ¹è¿­, UDF ÇÔ¼öµéÀ» ÀÌ¿ëÇÏ°í ÀÎÅͺ£À̽º ÅøµéÀ» ¼³¸íÇÏ´Â µÎ¹ø° °­Á¸¦ ½áº¼ °ÍÀÔ´Ï´Ù. Áö±ÝÀº ÀÌ °­ÁÂÀÇ »ùÇà ÄÚµå¿Í º¼·£µå¿¡¼­ Á¦°øÇÑ »ùÇà µ¥ÀÌÅͺ£À̽º¸¦ »ìÆ캸½Ã±â ¹Ù¶ø´Ï´Ù.


ÀÛ¼º ³¯Â¥ : 2008-06-21