>  기사  >  데이터 베이스  >  Writing to a MySQL database from SSIS_MySQL

Writing to a MySQL database from SSIS_MySQL

PHP中文网
PHP中文网원래의
2016-05-27 13:46:341513검색

A couple of users reported being unable to use the ADO.NET destination to insert data into their mysql databases. When I originally tried this out, it worked, but it seems like changes made since the early 2008 CTPs have made us incompatible with MySQL. We do have a bug logged to make this more flexible, but the good news is that in the meantime there is a workaround when using the ODBC connector.

 

For the ADO.NET Destination to work properly, the MySQL database needs to have the ANSI_QUOTES SQL_MODEoption enabled. This option can be enabled globally, or for a particular session. To enable it for a single session:

 

Create an ADO.NET Connection Manager which uses the ODBC driver

Set the connection manager’s RetainSameConnection property to True

Add an Execute SQL Task before your data flow to set the SQL_MODE – Ex. set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES'

Make sure that your Execute SQL Task and your ADO.NET Destination are using the same connection manager.

Setting the RetainSameConnection property to True will ensure that your Execute SQL Task and ADO.NET Destination are in the same session.

 

Note, I recommend using the ODBC Driver when writing to the MySQL database, because the MySQL .NET Connector has an additional blocking issue. If you try it out, you’ll get an error which looks something like this:

 

Error: 2009-01-05 12:03:47.79 

   Code: 0xC020844B 

   Source: Data Flow Task 1 Destination - Query [28] 

   Description: An exception has occurred during data insertion, the message returned from the provider is: You have an 

error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use nea 

r '"name", "date", "type", "remark") VALUES (p1, p2, p3, p4), (p1,p2,p3,p4), (p1,p2' at line 1 

End Error

 

Note that the “VALUES” portion has parameter names, and not the actual values. This appears to be an issue with the value the MySQL provider returns for its ParameterMarkerFormat. I did find a bug that was opened against them, but it looks like they decided not to fix it. I’ve heard that the DevArt dotConnect drivers do not have this problem, but I haven’t been able to try them out myself.

以上就是Writing to a MySQL database from SSIS_MySQL的内容,更多相关内容请关注PHP中文网(www.php.cn)!


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.