ug_ch11.htm

来自「db.* (pronounced dee-be star) is an adva」· HTM 代码 · 共 693 行 · 第 1/2 页

HTM
693
字号
<p><b><font size="2">d_recread</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_trbegin</font></b></p></td></tr><tr><td width="28%" valign="top"><p><b><font size="2">d_dbdpath</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_keyfind</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_recset</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_trend</font></b></p></td></tr><tr><td width="28%" valign="top"><p><b><font size="2">d_dbfpath</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_keyfree</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_recwrite</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_wrcurr</font></b></p></td></tr><tr><td width="28%" valign="top"><p><b><font size="2">d_dblog</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_keyfrst</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_renfile</font></b></p></td><td width="24%" valign="top">&nbsp;</td></tr><tr><td width="28%" valign="top"><p><b><font size="2">d_dbtaf</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_keylast</font></b></p></td><td width="24%" valign="top"><p><b><font size="2">d_rlbclr</font></b></p></td><td width="24%" valign="top">&nbsp;</td></tr></table><h2><a name="Commands" id="Commands"></a>11.6 dal-SpecificCommands</h2><p><font size="2">This section describes how variables are definedfor <b>dal</b> and explains the <b>dal</b>-specific commands thathelp make the utility more useful as a learning and prototypingtool.</font></p><hr><h3><a name="def_rec" id="def_rec"></a>def_rec, def_fld</h3><p><font size="2">Variables are defined in one of twoways:</font></p><p>1. <i>Implicitly</i> : A variable can be created from thecontext of a statement. The statement below causes a variable named"<b>per</b>" to be defined as the same type as the currentrecord.</p><pre><font color="#0000FF">keyfind(pers_name,"Norm");recread(per);</font></pre><p><font size="2">The next statement causes a variable named"<b>addr</b>" to be defined as a field with the same type as the"<b>pers_addr</b>" field in the schema.</font></p><pre><font color="#0000FF">crread(pers_addr,addr);</font></pre><p><font size="2">The following statement causes a variable named"<b>dba</b>" to be defined as type <b>DB_ADDR.</b></font></p><pre><font color="#0000FF">crget(dba);</font></pre><p><font size="2">2. <i>Explicitly</i> : Two functions are providedto explicitly create and type record or field variables:</font></p><pre><font color="#0000FF">def_rec(rec_type,var_name);</font></pre><p><font size="2">or</font></p><pre><font color="#0000FF">def_fld(fld_type,var_name);</font></pre><p><font size="2">The <b>def_rec</b> function creates a variable(named <b>var_name</b>) that is defined with the same type as therecord specified by <b>rec_type</b>. <b>def_fld</b> creates avariable (named <b>var_name</b>) that is defined with the same typeas the field specified by <b>fld_type</b>.</font></p><hr><h3><a name="abort" id="abort"></a>abort</h3><p><font size="2">Exit <b>dal</b> immediately without closingdatabase</font></p><h5>Summary</h5><pre><font color="#0000FF">abort;</font></pre><h5>Description</h5><p><font size="2">This command causes <b>dal</b> to stopimmediately without closing the database. Any data remaining in the<b><i>db.*</i></b> cache will not be written to the database. Ifyou have created only a few changes or additions (such that all thedata fits into the cache), then none of your work will be saved.However, be aware that indiscriminate use of the <b>abort</b>command can lead to database corruption in the event that somechanges get written to disk while the remaining are lost when youabort. You must be concerned about this only if you are not usingtransactions.</font></p><hr><h3><a name="curr" id="curr"></a>curr</h3><p><font size="2">Print the currency tables.</font></p><h5>Summary</h5><pre><font color="#0000FF">curr;</font></pre><h5>Description</h5><p><font size="2">This command causes <b>dal</b> to print out thecurrency tables, showing current database, current record, andcurrent owners and members for each set.</font></p><hr><h3><a name="exit" id="exit"></a>exit</h3><p><font size="2">Exit <b>dal</b>.</font></p><h5>Summary</h5><pre><font color="#0000FF">exit;</font></pre><h5>Description</h5><p><font size="2">This command calls <b>d_close</b> to close thedatabase, and exit with a code of zero (that is, callexit).</font></p><hr><h3><a name="input" id="input"></a>input</h3><p><font size="2">Read values into a variable.</font></p><h5>Summary</h5><pre><font color="#0000FF">input [(filename)] var_name [,var_name ]...;</font></pre><h5>Description</h5><p><font size="2">This command reads variable values from thekeyboard or a file. If a variable is a record, then the individualfield values will be requested with separate prompts. If a filename is specified for input, one line from the file will be readfor each variable listed. File names must be enclosed in quotes.Fields within a line are in fixed format with the following lengthsfor different field types:</font></p><table border="1" cellspacing="1" cellpadding="7" width="295"><tr><td width="35%" valign="top"><p><b><font face="Palatino" size="2">Char</font></b></p></td><td width="65%" valign="top"><p><b><font face="Palatino" size="2">Length specified inschema</font></b></p></td></tr><tr><td width="35%" valign="top"><p><b><font face="Palatino" size="2">int</font></b></p></td><td width="65%" valign="top"><p><font face="Palatino" size="2">6</font></p></td></tr><tr><td width="35%" valign="top"><p><b><font face="Palatino" size="2">short</font></b></p></td><td width="65%" valign="top"><p><font face="Palatino" size="2">6</font></p></td></tr><tr><td width="35%" valign="top"><p><b><font face="Palatino" size="2">long</font></b></p></td><td width="65%" valign="top"><p><font face="Palatino" size="2">10</font></p></td></tr><tr><td width="35%" valign="top"><p><b><font face="Palatino" size="2">float</font></b></p></td><td width="65%" valign="top"><p><font face="Palatino" size="2">10</font></p></td></tr><tr><td width="35%" valign="top"><p><b><font face="Palatino" size="2">double</font></b></p></td><td width="65%" valign="top"><p><font face="Palatino" size="2">10</font></p></td></tr></table><p><font size="2">Note that these widths are the same as thosecreated by the <b>print</b> command.</font></p><h5>Examples</h5><pre><font color="#0000FF">open("tims","o");def_rec(author,a);input a;            /* Get data from terminal */;fillnew(author,a);input ("auth.imp");      /* Get data from file */;fillnew(author,a);</font></pre><h5>Diagnostics</h5><p><font size="2">Errors can occur when input reads from a file andthe line lengths in the file are inconsistent.</font></p><hr><h3><a name="print" id="print"></a>print</h3><p><font size="2">Print values from a variable list.</font></p><h5>Summary</h5><pre><font color="#0000FF">print [(filename)] var_name [,var_name ...];</font></pre><h5>Description</h5><p><font size="2">This command prints one line of data to theterminal or to a file. If a variable is a record, then theindividual field values will be printed, with no spaces between thevalues, each field width being determined by the field type (seetable under input). Literal strings may be included in the<i>var_name</i> list. If a file name is specified for output, oneline will be written to the file for each print command. File namesmust be enclosed in quotes. If an output file is used within aninput command, the file is re-opened for input.</font></p><h5>Examples</h5><pre><font color="#0000FF">open("tims","o");findfm(author_list);recread(a);print "author:",a;crget(dba);print("author.lst") "dba:",dba,"author:",author;</font></pre><hr><h3><a name="rewind" id="rewind"></a>rewind</h3><p><font size="2">Rewind (or reset back to the beginning of) afile.</font></p><h5>Summary</h5><pre><font color="#0000FF">rewind "<i>filename</i>";</font></pre><h5>Description</h5><p><font size="2">This command rewinds a file. If the file wasopened for reading, then subsequent reads will start from thebeginning (that is, the first line will be reread). If the file wasopened for writing, it will be truncated and all previous data willbe lost.</font></p><hr><h3><a name="schema" id="schema"></a>schema</h3><p><font size="2">Print schema information.</font></p><h5>Summary</h5><pre><font color="#0000FF">schema <i>[spec]</i>;</font></pre><h5>Description</h5><p><font size="2">This command prints information about a databaseschema, including the record types, field types, and setinformation. The <b>schema</b> command with no arguments produces alist of the record names and set names. If <i>spec</i> is a record,then detailed information about the record is printed, including alist of the fields, and the field information for each field. If<i>spec</i> is a field name, then the type and length is printed.Additionally, if the field is a key, then the kind of key, and thekey file containing the key is printed. If <i>spec</i> is a setname, then order, owner type, member type(s), and sortinginformation is printed.</font></p><hr><h3><a name="whileok" id="whileok"></a>whileok</h3><p><font size="2">Repeat statements while (<b>db_status</b> ==S_OKAY).</font></p><h5>Summary</h5><pre><font color="#0000FF">whileok {   statements;      ...}</font></pre><h5>Description</h5><p><font size="2">This command functions in the same manner as thefollowing C code:</font></p><pre><font color="#0000FF">while (db_status == S_OKAY) {   statements;   ...}</font></pre><p><font size="2">Note that <b>whileok</b> statements can benested.</font></p><h5>Examples</h5><pre><font color="#0000FF">/* List all authors and their publications */open("tims","o");findfm(author_list);whileok {   recread(a);   print "Author:",a;   setor(has_published);   findfm(has_published);   whileok {      recread(b);      print "Published:",b;      findnm(has_published);   }   findnm(author_list);}</font></pre><h2><a name="Limitations" id="Limitations"></a>11.7 dalLimitations</h2><p><font size="2">The following is a list of <b><i>db.*</i></b>functions and functionalities <i>not</i> supported by<b>dal</b>:</font></p><p><font size="2">1. Group locking function (that is,<b>d_lock()</b>)<br>2. Timestamping functions<br>3. Currency functions (<b>d_rdcurr()</b>, <b>d_rerdcurr()</b>, and<b>d_wrcurr()</b>)<br>4. File rename functions (<b>d_renfile()</b> and<b>d_renclean()</b>)<br>5. Alternate initialization file location(<b>d_dbini()</b>)</font></p><p><font size="2">In addition,</font></p><p><font size="2">1. <b>dal</b> does not support multipledatabases.<br>2. <b>dal</b> does not support arrays.</font></p><p><a href="UG_Ch12.htm">Next Page</a></p></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?