17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3: Accessing <strong>FILESTREAM</strong> Data from Client Applications<strong>The</strong> next argument in Listing 3-36 specifies additional flags that help the system tooptimize the requested file operation. <strong>The</strong> different values this parameter can take aredescribed below.• <strong>SQL</strong>_<strong>FILESTREAM</strong>_OPEN_NONE – Indicates that you do not want to specify anyadditional flags.• <strong>SQL</strong>_<strong>FILESTREAM</strong>_OPEN_FLAG_NO_WRITE_THROUGH – Instructs the system to sendwrites directly to disk, bypassing any intermediate caches.• <strong>SQL</strong>_<strong>FILESTREAM</strong>_OPEN_FLAG_ASYNC – Informs the system that you intend to usethe file for asynchronous reading and writing.• <strong>SQL</strong>_<strong>FILESTREAM</strong>_OPEN_FLAG_RANDOM_ACCESS – Informs the system that youmight access the file randomly. <strong>The</strong> system will use this information to optimize filecaching for random access.• <strong>SQL</strong>_<strong>FILESTREAM</strong>_OPEN_FLAG_SEQUENTIAL_SCAN – Informs the system thatyou will use the file sequentially. When this flag is specified, the system optimizes thefile operations on the basis that you will not access the file backwards or jump into arandom location in the file.• <strong>SQL</strong>_<strong>FILESTREAM</strong>_OPEN_FLAG_NO_BUFFERING – Requests the system to open thefile with no buffering support.<strong>The</strong> next argument in Listing 3-36 (transactionToken) is the <strong>FILESTREAM</strong> transactioncontext retrieved by calling T-<strong>SQL</strong> function GET_<strong>FILESTREAM</strong>_TRANSACTION_CONTEXT(). This is followed by another parameter, cbTransactionToken, whichspecifies the size <strong>of</strong> the buffer that stores the <strong>FILESTREAM</strong> transaction context.<strong>The</strong> final parameter in Listing 3-36 specifies the initial allocation size <strong>of</strong> the data filein bytes. This parameter is ignored when the file is opened for READ operation. If thisparameter is NULL, the system will use the default allocation size.128

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!