📄 rm_ch3.htm
字号:
of the <b>d_setfiles</b> function, or uses the 8 default filehandles. If at some point in an application more file handles areneeded, this function may be called.</font></p><blockquote><b><i>Note:</i></b> Care should be taken in designingthe application so that extra handles are released, allowing<b><i>db.*</i></b> to reopen the files on an as-neededbasis.</blockquote><h4>Currency Changes</h4><p><font size="2">None.</font></p><h4>Locking Requirements</h4><p><font size="2">None.</font></p><h4>Return Codes</h4><p><font size="2">None.</font></p><h4>Example</h4><pre><font color="#0000FF">/* Open a report file */rpt[i] = fopen( rpt_name, "w" );if ( rpt[i] == NULL ){ /* Try to obtain more handles */ d_closeall(task); rpt[i] = fopen( rpt_name, "w" ); if ( rpt[i] == NULL ) { /* None available */ fprintf( stderr, "Out of file handles\n" ); d_close(task); exit(1); }}/* Produce the report */...fclose(rpt[i]);</font></pre><h4>See Also</h4><p><font size="2">None.</font></p><p> </p><hr><h3><a name="d_closetask" id="d_closetask"></a>d_closetask</h3><p><font size="2">Close a database task</font></p><h4>Prototypes</h4><p><font size="2">int <b>d_closetask</b>(DB_TASK*<i>task</i>)</font></p><h4>Parameters</h4><p><font size="2">task<br>A pointer to a DB_TASK structure.</font></p><h4>Description</h4><p><font size="2">This function will free the memory associatedwith a database task. The <b>dt_opentask</b> function mustpreviously have created the task, and any databases opened withinthe task must first be closed.</font></p><h4>Currency Changes</h4><p><font size="2">None.</font></p><h4>Locking Requirements</h4><p><font size="2">None.</font></p><h4>Return Codes</h4><p><font size="2">S_DBCLOSE<br>Task not opened.</font></p><p>S_INVPTR<br>Invalid task pointer.</p><h4>Example</h4><pre><font color="#0000FF">DB_TASK task;d_opentask(&task);d_open("db", "o", &task);d_makenew(REC, &task, 0);d_close(&task);d_closetask(&task);</font></pre><h4>See Also</h4><p><b><font size="2">d_opentask</font></b></p><p> </p><hr><h3><a name="d_cmstat" id="d_cmstat"></a>d_cmstat</h3><p><font size="2">Test timestamp status of currentmember</font></p><h4>Prototypes</h4><p><font size="2">int <b>d_cmstat</b>(int <i>SET</i>, DB_TASK*<i>task</i>, int <i>dbn</i>)</font></p><h4>Parameters</h4><p><font size="2">SET<br>The set whose current member's status is checked.</font></p><p>task<br>A pointer to a DB_TASK structure.</p><p>dbn<br>The database number.</p><h4>Description</h4><p><font size="2">The <b>d_cmstat</b> function tests the status ofthe timestamp in the currency table of the current member of<i>SET</i> against the timestamp on the disk. The current memberrecord type must have been specified as timestamped in the DDLschema file for the database. The timestamp status is returned asdefined below.</font></p><h4>Currency Changes</h4><p><font size="2">None.</font></p><h4>Locking Requirements</h4><p><font size="2">Allowed with no locks, but may read old ordeleted data. Use a read lock on <i>SET</i> to ensure currentdata.</font></p><h4>Return Codes</h4><p><font size="2">S_DELETED<br>The current member has been deleted since it was lastaccessed.</font></p><p>S_INVSET<br>Invalid set type. Probably passed a record type instead of a settype.</p><p>S_OKAY<br>The current member has not been changed by another user since lastaccessed.</p><p>S_TIMESTAMP<br>The current member record type is not timestamped.</p><p>S_UPDATED<br>The current member was modified since last accessed.</p><h4>Example</h4><pre><font color="#0000FF">if ( d_cmstat(HAS_PUBLISHED, task, CURR_DB) == S_OKAY ){ d_csmread(HAS_PUBLISHED, INFO_TITLE, title, task, CURR_DB); ...}</font></pre><h4>See Also</h4><p><b><font size="2">d_costat, d_crstat, d_csstat, d_gtscm,d_recstat, d_stscm</font></b></p><p> </p><hr><h3><a name="d_cmtype" id="d_cmtype"></a>d_cmtype</h3><p><font size="2">Get record type of current member</font></p><h4>Prototypes</h4><p><font size="2">int <b>d_cmtype</b>(int <i>SET</i>, int*<i>rectype</i>, DB_TASK *<i>task</i>, int <i>dbn</i>)</font></p><h4>Parameters</h4><p><font size="2">SET<br>The set type to which the current member record type isreturned.</font></p><p>rectype<br>A pointer to an integer variable that contains the returned recordtype.</p><p>task<br>A pointer to a DB_TASK structure.</p><p>dbn<br>The database number.</p><h4>Description</h4><p><font size="2">This function copies the record type of thecurrent <i>SET</i> member into the integer variable to which<i>rectype</i> points. This function is particularly useful indetermining the type of the current member of multiple membersets.</font></p><h4>Currency Changes</h4><p><font size="2">None.</font></p><h4>Locking Requirements</h4><p><font size="2">Allowed with no locks, but old or deleted datamay be read. Use a read lock to ensure that only current data isread.</font></p><h4>Return Codes</h4><p><font size="2">S_INVSET<br>Invalid set type. A record or field type, instead of a set type,was probably passed.</font></p><p>S_NOCM<br>The current member for the specified set is null.</p><h4>Example</h4><pre><font color="#0000FF">int rtype; /* record type */long fld; /* field type */char txt[80]; /* comment text */...d_cmtype(COMMENTS, &rtype, task, CURR_DB); switch ( rtype ){ case TEXT30: fld = T30_LINE; break; case TEXT55: fld = T55_LINE; break; case TEXT80: fld = T80_LINE; break;}d_csmread(COMMENTS, fld, &txt, task, CURR_DB);</font></pre><h4>See Also</h4><p><b><font size="2">d_cotype, d_crtype</font></b></p><p> </p><hr><h3><a name="d_connect" id="d_connect"></a>d_connect</h3><p><font size="2">Connect current record to set</font></p><h4>Prototypes</h4><p><font size="2">int <b>d_connect</b>(int <i>SET</i>, DB_TASK*<i>task</i>, int <i>dbn</i>)</font></p><h4>Parameters</h4><p><font size="2">SET<br>The set type to which the current record is connected.</font></p><p>task<br>A pointer to a DB_TASK structure.</p><p>dbn<br>The database number.</p><h4>Description</h4><p><font size="2">The function <b>d_connect</b> connects thecurrent record to the current owner of <i>SET</i>. The record isplaced into <i>SET</i> in the order specified in the DDL for thedatabase. Upon successful completion, the current record becomesthe current member of <i>SET</i>.</font></p><h4>Currency Changes</h4><p><font size="2">curr_mem[<i>SET</i>] = curr_rec;</font></p><h4>Locking Requirements</h4><p><font size="2">Write lock on <i>SET</i>, or write locks on ownerand member record types. Key files need not be locked.</font></p><h4>Return Codes</h4><p><font size="2">S_INVSET<br>Invalid set type. Probably passed a record or field type instead ofa set type.</font></p><p>S_ISOWNED<br>The current record is already owned as a member of <i>SET</i>. Ifyou want to change a set connection, you first need to disconnectthe record from the current owner, set the current owner of<i>SET</i> to the new owner record, and then connect the currentrecord to the new owner record.</p><p>S_NOCO<br>The current owner for the specified set is null. Find the correctowner record occurrence, and set the current owner of <i>SET</i> tothe located record (for example, using function<b>d_setor</b>).</p><p>S_NOCR<br>The current record is null.</p><p>S_NOTLOCKED<br>A data file named in the definition of <i>SET</i> has not beenlocked.</p><p>S_NOTRANS<br>In shared mode, changes can only be made from within a transactionexcept when the affected files are exclusively locked.</p><h4>Example</h4><pre><font color="#0000FF">struct info irec; /* tech. info record */.../* make author record current owner of has_published */d_setor(HAS_PUBLISHED, task, CURR_DB);.../* create new info record */if ( d_fillnew(INFO, &irec, task, CURR_DB) == S_OKAY ) /* connect new record to has_published set */ d_connect(HAS_PUBLISHED, task, CURR_DB);</font></pre><h4>See Also</h4><p><b><font size="2">d_discon, d_disdel</font></b></p><p> </p><hr><h3><a name="d_costat" id="d_costat"></a>d_costat</h3><p><font size="2">Test timestamp status of current owner</font></p><h4>Prototypes</h4><p><font size="2">int <b>d_costat</b>(int <i>SET</i>, DB_TASK*<i>task</i>, int <i>dbn</i>)</font></p><h4>Parameters</h4><p><font size="2">SET<br>The set whose current owner's status is checked.</font></p><p>task<br>A pointer to a DB_TASK structure.</p><p>dbn<br>The database number.</p><h4>Description</h4><p><font size="2">This function tests the status of the timestampin the currency table of the current owner of <i>SET</i> againstthe timestamp on the disk. The current owner record type must havebeen specified as timestamped in the DDL schema file for thedatabase. The timestamp status is returned as definedbelow.</font></p><h4>Currency Changes</h4><p><font size="2">Allowed with no locks, but may read old ordeleted data. Use a read lock on <i>SET</i> to ensure currentdata.</font></p><h4>Locking Requirements</h4><p><font size="2">None.</font></p><h4>Return Codes</h4><p><font size="2">S_DELETED<br>The current owner has been deleted since it was lastaccessed.</font></p><p>S_INVSET<br>Invalid set type. Probably passed a record type instead of a settype.</p><p>S_OKAY<br>The current owner has not been changed by another user since it waslast accessed.</p><p>S_TIMESTAMP<br>The current owner record type is not timestamped.</p><p>S_UPDATED<br>The current owner was modified since last accessed.</p><h4>Example</h4><pre><font color="#0000FF">if ( d_costat(HAS_PUBLISHED, task, CURR_DB) == S_OKAY ){ d_csoread(HAS_PUBLISHED, INFO_TITLE, title, task, CURR_DB); ...}</font></pre><h4>See Also</h4><p><b><font size="2">d_cmstat, d_crstat, d_csstat, d_gtsco,d_recstat, d_stsco</font></b></p><p> </p><hr><h3><a name="d_cotype" id="d_cotype"></a>d_cotype</h3><p><font size="2">Get record type of current owner</font></p><h4>Prototypes</h4><p><font size="2">int <b>d_cotype</b>(int <i>SET</i>, int*<i>rectype</i>, DB_TASK *<i>task</i>, int <i>dbn</i>)</font></p><h4>Parameters</h4><p><font size="2">SET<br>The set type for which the current owner record type is to bereturned.</font></p><p>rectype<br>A pointer to an integer variable that contains the returned recordtype.</p><p>task<br>A pointer to a DB_TASK structure.</p><p>dbn<br>The database number.</p><h4>Description</h4><p><font size="2">This function copies the record type of thecurrent owner of <i>SET</i> into the integer variable to which<i>rectype</i> points.</font></p><h4>Currency Changes</h4><p><font size="2">None.</font></p><h4>Locking Requirements</h4><p><font size="2">Allowed with no locks, but may read old ordeleted data. Use a read lock on <i>SET</i> to ensure currentdata.</font></p><h4>Return Codes</h4><p><font size="2">S_INVSET<br>Invalid set type. Probably passed a record or field type instead ofa set type.</font></p><p>S_NOCO<br>The current owner for the specified set is null.</p><h4>Example</h4>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -