Re: How to apply Bulk Copy hints when using ctlib ?
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Mar 03, 2011 at 01:21:53PM +0200, Mark Songhurst wrote: > I'm using FreeTDS 0.82 on Linux RedHat Enterprise 4.0 x64. My database > is MS SQL Server 2008 Standard Edition. > I'm programming in C and using the ctlib API of FreeTDS. ... > I need the constraint active during the bulk copy to ensure bad data > is rejected (it's ok for the whole bulk copy to fail if only one data > item is bad). ... > Please can you suggest how I can keep constraints enabled during a > bulk copy using the ctlib API? To do that, you'll need to modify ct-lib. Hard, but not too hard. In db-lib, we extended the possible values of bcp_options to include hints, and allowed hints to be passed as literal strings. See src/dblib/bcp.c::bcp_options(). You can extend blk_props in the same way. As long as blkdesc->bcpinfo.hint points to a valid string e.g. "CHECK_CONSTRAINTS", the tds library will send it to the server before sending the first row. It should work! :-) HTH. --jkl