Difference between revisions of "SCAN"

From Lianjapedia
Jump to: navigation, search
(Description)
 
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
 
 
==Purpose==
 
==Purpose==
 
Scans over records in a table and executes a command block for each selected record.
 
Scans over records in a table and executes a command block for each selected record.
  
 
==Syntax==
 
==Syntax==
SCAN [<scope>] [FOR <condition>] [WHILE <condition>]
+
SCAN  
 +
 
 +
[IN <workarea>|<alias>]
 +
 
 +
[<scope>]  
 +
 
 +
[FOR <condition>]  
 +
 
 +
[WHILE <condition>]
  
 
[EXIT]
 
[EXIT]
Line 12: Line 18:
  
 
ENDSCAN
 
ENDSCAN
 
  
 
==See Also==
 
==See Also==
[[CONTINUE]], [[DO WHILE]], [[IF]], [[LOCATE]]
+
[[CONTINUE]], [[DO WHILE]], [[EXIT]], [[IF]], [[LOCATE]], [[LOOP]]
 
+
  
 
==Description==
 
==Description==
The SCAN ... ENDSCAN command executes a command block repeatedly FOR a specified selection of records WHILE an optionally specified condition is true, or until an EXIT is encountered.  The optional LOOP keyword forces control to the beginning of the SCAN.
+
The SCAN...ENDSCAN command executes a command block repeatedly FOR a specified selection of records WHILE an optionally specified condition is true, or until an EXIT is encountered.  The optional LOOP keyword forces control to the beginning of the SCAN.
 +
 
 +
The SCAN...ENDSCAN command can be used to reduce the programming involved in a LOCATE...DO WHILE...CONTINUE construct.
 +
 
 +
====IN <workarea>|<alias>====
 +
If the workarea number, letter or alias name is specified, the SCAN is carried out in that workarea.  Note, the IN clause must be the first clause.  From v6.0.
 +
 
 +
====<scope>====
 +
The default [[SCOPE]] is all records unless a FOR or WHILE condition is specified.
 +
 
 +
====FOR <condition>====
 +
If the FOR clause is specified, then only those records which satisfy the <condition> are deleted.  The default [[SCOPE]] is ALL.
 +
 
 +
====WHILE <condition>====
 +
The WHILE clause can be used to restrict the number of records checked against a particular <condition>, therefore optimizing the scan.  The default [[SCOPE]] is REST.
 +
 
 +
====EXIT====
 +
The looping will continue until either ENDSCAN is reached or an EXIT command is encountered.
  
The SCAN...ENDSCAN command can be used to reduce the programming involved in a LOCATE ... DO WHILE ... CONTINUE construct.
+
====LOOP====
 +
If a LOOP command is encountered, then control returns to the start of the loop.
  
 
==Example==
 
==Example==
Line 32: Line 54:
 
</code>
 
</code>
  
==Products==
 
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
[[Category:Table Basics]]
+
[[Category:Looping Commands]]
[[Category:Table Basics Commands]]
+
[[Category:NoSQL Commands]]
[[Category:Data Commands]]
+

Latest revision as of 08:37, 4 January 2021

Purpose

Scans over records in a table and executes a command block for each selected record.

Syntax

SCAN

[IN <workarea>|<alias>]

[<scope>]

[FOR <condition>]

[WHILE <condition>]

[EXIT]

[LOOP]

ENDSCAN

See Also

CONTINUE, DO WHILE, EXIT, IF, LOCATE, LOOP

Description

The SCAN...ENDSCAN command executes a command block repeatedly FOR a specified selection of records WHILE an optionally specified condition is true, or until an EXIT is encountered. The optional LOOP keyword forces control to the beginning of the SCAN.

The SCAN...ENDSCAN command can be used to reduce the programming involved in a LOCATE...DO WHILE...CONTINUE construct.

IN <workarea>|<alias>

If the workarea number, letter or alias name is specified, the SCAN is carried out in that workarea. Note, the IN clause must be the first clause. From v6.0.

<scope>

The default SCOPE is all records unless a FOR or WHILE condition is specified.

FOR <condition>

If the FOR clause is specified, then only those records which satisfy the <condition> are deleted. The default SCOPE is ALL.

WHILE <condition>

The WHILE clause can be used to restrict the number of records checked against a particular <condition>, therefore optimizing the scan. The default SCOPE is REST.

EXIT

The looping will continue until either ENDSCAN is reached or an EXIT command is encountered.

LOOP

If a LOOP command is encountered, then control returns to the start of the loop.

Example

use customers
seek "HMT"
scan rest while code = "HMT"
    echo "name=" + name + "address=" + address
endscan