11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

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.

<strong>Caché</strong> <strong>ObjectScript</strong> CommandsAfter reading a block into the view buffer, you can use the $VIEW function to examine thedata. Or, you can use the VIEW command to modify the data. If you modify the data, youcan use the VIEW command again to write the modified block back to the <strong>Caché</strong> database.Reading and Writing Data in a <strong>Caché</strong> DatabaseBefore you can read and write data blocks in a <strong>Caché</strong> database with VIEW, you must firstuse the OPEN command to open the view buffer.1. Open the view buffer. The view buffer is designated as device number 63. Hence thecommand is:OPEN 63:locationwhere location is the namespace that contains the CACHE.DAT to be associated withthe view buffer. The location is implementation specific. The OPEN 63 command createsthe view buffer by allocating a region of system memory whose size is equal to the blocksize used by the <strong>Caché</strong> database.2. Use the VIEW block form to read in a block from the associated <strong>Caché</strong> database. Specifyblock as a positive integer. For example:VIEW 4This example reads the fourth block from the <strong>Caché</strong> database into the view buffer. Becausethe size of the view buffer equals the block size used in the <strong>Caché</strong> database, the viewbuffer can contain only one block at any given time. As you read in subsequent blocks,each new block overwrites the current block. To determine which blocks to read in fromthe <strong>Caché</strong> database, you should be familiar with the structure of the file.3. Read the data in the block with $VIEW function or modify it with the VIEW command.4. If you changed any of the data in the view buffer, write it back to the <strong>Caché</strong> database.To write data, use the VIEW block form but specify a negative integer for block. Theblock number usually matches the number of the current block in the view buffer, but itdoes not have to. The specified block number identifies which block in the file will bereplaced (overwritten) by the block in the view buffer. For example: VIEW 5 Thisexample replaces the fifth block in the <strong>Caché</strong> database with the current block in the viewbuffer.5. Close the view buffer. CLOSE 63154 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

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

Saved successfully!

Ooh no, something went wrong!