Difference between revisions of "Using Navigational Data Access Commands in Recital"

From Recital Documentation Wiki
Jump to: navigation, search
(Using Navigational Data Access Commands in Recital)
(Deleting Records in a Recital Table)
Line 85: Line 85:
  
 
===Deleting Records in a Recital Table===
 
===Deleting Records in a Recital Table===
The deletion of records in a Recital table is a two stage process.  The ''delete'' command is used to mark a record for deletion.  At this stage, the marked record is hidden if ''set deleted'' is ''on''.  With ''set deleted'' set to ''off'', the record is still accessible as normal.  Record lists (''list'' and ''display'') will show the deletion marker ''*'' next to the record number and the ''deleted()'' function will return .T. (true).  A record marked for deletion can have the mark removed using the ''recall'' command.
+
The deletion of records in a Recital table is a two stage process.  The [[DELETE|delete]] command is used to mark a record for deletion.  At this stage, the marked record is hidden if [[SET DELETED|set deleted]] is ''on''.  With [[SET DELETED|set deleted]] set to ''off'', the record is still accessible as normal.  Record lists ([[LIST|list]] and [[DISPLAY|display]]) will show the deletion marker ''*'' next to the record number and the [[DELETED()|deleted()]] function will return .T. (true).  A record marked for deletion can have the mark removed using the [[RECALL|recall]] command.
 
+
* [[DELETE|delete]]
+
  
 
<pre>
 
<pre>
 
delete [<scope>][for | while <condition as logical>]  
 
delete [<scope>][for | while <condition as logical>]  
 
</pre>
 
</pre>
 
* [[RECALL|recall]]
 
  
 
<pre>
 
<pre>
 
recall [<scope>][for | while <condition as logical>]  
 
recall [<scope>][for | while <condition as logical>]  
 
</pre>
 
</pre>
 
* [[SET DELETED|set deleted]]
 
  
 
<pre>
 
<pre>
Line 115: Line 109:
 
</code>
 
</code>
  
To physically remove records marked for deletion, the ''pack'' command must be issued on the table.  The table must be open for exclusive use.
+
To physically remove records marked for deletion, the [[PACK|pack]] command must be issued on the table.  The table must be open for exclusive use.
 
+
* [[PACK|pack]]
+
  
 
<code lang="recital">
 
<code lang="recital">
Line 124: Line 116:
 
</code>
 
</code>
  
The ''zap'' command can be used to physically delete all the records from a table immediately.  The table must be open for exclusive use.
+
The [[ZAP|zap]] command can be used to physically delete all the records from a table immediately.  The table must be open for exclusive use.
 
+
* [[ZAP|zap]]
+
  
 
<code lang="recital">
 
<code lang="recital">

Revision as of 10:16, 7 January 2010

Using Navigational Data Access Commands in Recital

Why use Navigational Data Access Commands

Creating a Recital Database

The create database command is used to create a new database. This will create a sub-directory in the DB_DATADIR directory and a database catalog with the same name as the database specified.

create database [if not exists] <database>

A database, its tables and other associated files can be physically deleted using the drop database command.

drop database [if exists] <database>

Example

create database test
drop database test

Opening a Recital Database

To open a database and set it as the default database for any subsequent operations, use the open database command.

open database <database> [EXCLUSIVE | SHARED] [NOUPDATE] [VALIDATE]

The open database command triggers the DBC_OPENDATA database event. If a dbc_opendata.prg program file exists in the database's directory, this will be run. If the dbc_opendata.prg program returns .F. (False), the open database operation will be abandoned.

Databases can also have an associated procedure library that is activated automatically when the database is opened. The procedure library must follow the naming convention dbc_<database>_library.prg and must exist in the database's directory. When the database is closed, the procedure library is also closed.

open database southwind

Creating a Recital Table

  • CREATE
  • CREATE FROM
  • COPY STRUCTURE
  • COPY TO
  • COPY STRUCTURE EXTENDED
  • SQL CREATE TABLE

Opening a Recital Table

  • SELECT
  • SELECT()
  • USE

Navigating a Recital Table

  • GOTO
  • GOTO()
  • INDEX
  • REINDEX
  • SEEK
  • SEEK()
  • SKIP

Inserting Records into a Recital Table

  • APPEND FROM
  • BLANK
  • GATHER
  • GENERATE
  • REPLACE

Updating Records in a Recital Table

  • GATHER
  • REPLACE

Selecting Records from a Recital Table

  • AVERAGE
  • COUNT
  • DISPLAY
  • LIST
  • SCAN
  • SCATTER
  • SUM
  • TOTAL

Adding Records to a Recital Table

  • APPEND
  • APPEND BLANK
  • INSERT

Deleting Records in a Recital Table

The deletion of records in a Recital table is a two stage process. The delete command is used to mark a record for deletion. At this stage, the marked record is hidden if set deleted is on. With set deleted set to off, the record is still accessible as normal. Record lists (list and display) will show the deletion marker * next to the record number and the deleted() function will return .T. (true). A record marked for deletion can have the mark removed using the recall command.

delete [<scope>][for | while <condition as logical>] 
recall [<scope>][for | while <condition as logical>] 
set deleted on | off 
set deleted off
use example
goto 10
delete
echo deleted() // .T.
recall
echo deleted() // .F.

To physically remove records marked for deletion, the pack command must be issued on the table. The table must be open for exclusive use.

use example exclusive
pack

The zap command can be used to physically delete all the records from a table immediately. The table must be open for exclusive use.

use example exclusive
zap

Obtain Information about a Recital Table

  • DISPLAY/LIST STRUCTURE
  • DISPLAY/LIST INDEX
  • DISPLAY/LIST
  • BOF()
  • EOF()
  • FIELD()
  • FIELDNAME()
  • FLDLIST()
  • INUSE()
  • RECNO()
  • REFERENCES()
  • USED()