Difference between revisions of "Using Navigational Data Access Commands in Recital"
Yvonnemilne (Talk | contribs) (→Creating a Recital Table) |
Yvonnemilne (Talk | contribs) (→Creating a Recital Table) |
||
Line 48: | Line 48: | ||
use example order account_no | use example order account_no | ||
copy to new; | copy to new; | ||
+ | rest; | ||
fields account_no, last_name; | fields account_no, last_name; | ||
while account_no < "00050"; | while account_no < "00050"; |
Revision as of 10:41, 7 January 2010
Contents
- 1 Using Navigational Data Access Commands in Recital
- 1.1 Why use Navigational Data Access Commands
- 1.2 Creating a Recital Database
- 1.3 Opening a Recital Database
- 1.4 Creating a Recital Table
- 1.5 Opening a Recital Table
- 1.6 Navigating a Recital Table
- 1.7 Inserting Records into a Recital Table
- 1.8 Updating Records in a Recital Table
- 1.9 Selecting Records from a Recital Table
- 1.10 Adding Records to a Recital Table
- 1.11 Deleting Records in a Recital Table
- 1.12 Obtain Information about a Recital Table
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
Tables can be created using the SQL create table statement. For full details, please see Using Recital SQL.
The copy command can be used to copy all or part of an active table to a new table. The records to be copied can be restricted using for and while conditions.
copy to <filename> [<scope>] [fields <field list>] [for <condition>] [while <condition>]
use example order account_no copy to new; rest; fields account_no, last_name; while account_no < "00050"; for state = "MA"
The copy structure command allows the entire structure or selected fields from an existing active table to be copied to a new table.
copy structure to <tablename> [fields <field list>]
- CREATE
- CREATE FROM
- COPY STRUCTURE EXTENDED
Opening a Recital Table
- SELECT
- SELECT()
- USE
- 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()