Difference between revisions of "REFERENCES()"

From Lianjapedia
Jump to: navigation, search
Line 4: Line 4:
 
==Syntax==
 
==Syntax==
 
REFERENCES(<key expression>, <workarea | alias> [,<tag name>])
 
REFERENCES(<key expression>, <workarea | alias> [,<tag name>])
 +
 +
REFERENCES(<key expression>, <table name>, <tag name>)
  
 
==See Also==
 
==See Also==
Line 10: Line 12:
 
==Description==
 
==Description==
 
The REFERENCES() function looks up the specified <key expression> in the master tag index of the specified <workarea | alias>.  The <workarea | alias> is the workarea or alias name of an open table.  To search in a tag index which is not the current master index, the optional <tag name> parameter can be used.  The tag name must be specified as a string.
 
The REFERENCES() function looks up the specified <key expression> in the master tag index of the specified <workarea | alias>.  The <workarea | alias> is the workarea or alias name of an open table.  To search in a tag index which is not the current master index, the optional <tag name> parameter can be used.  The tag name must be specified as a string.
 +
 +
If the target table is not open, but is in the active database, it can be specified as a string: <table name>.  The tag name <tag name> string must also be specified.
  
 
The REFERENCES() function returns True (.T.) or False (.F.), depending on the success of the lookup operation.
 
The REFERENCES() function returns True (.T.) or False (.F.), depending on the success of the lookup operation.
Line 17: Line 21:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
use customer.rdb
+
open database southwind
index on account_no tag account_no
+
use customers order customerid in 2
index on upper(last_name) tag uplast
+
use orders in 1
index on zip tag zip
+
? references(customerid,2)
? references("STEREK",customer,"uplast")
+
.T.
 +
? references(customerid,customers)
 +
.T.
 +
 
 +
select customers
 +
set order to address
 +
select orders
 +
// Specify the index tag string to search in non-master index
 +
? references(customerid,2,"customerid")
 +
.T.
 +
? references(customerid,customers,"customerid")
 +
.T.
 +
 
 +
select customers
 +
use
 +
select orders
 +
// customers table is not currently open
 +
? references(customerid,"customers","customerid")
 
.T.
 
.T.
 
</code>
 
</code>

Revision as of 08:47, 28 October 2019

Purpose

Function to perform a cross-table lookup for a specified key expression

Syntax

REFERENCES(<key expression>, <workarea | alias> [,<tag name>])

REFERENCES(<key expression>, , <tag name>)

See Also

ALIAS(), INDEX, KEY(), KEYMATCH(), LOOKUP(), RLOOKUP(), SEEK, SEEK(), SET RELATION, TAG(), TAGCOUNT(), TAGNO()

Description

The REFERENCES() function looks up the specified <key expression> in the master tag index of the specified <workarea | alias>. The <workarea | alias> is the workarea or alias name of an open table. To search in a tag index which is not the current master index, the optional <tag name> parameter can be used. The tag name must be specified as a string.

If the target table is not open, but is in the active database, it can be specified as a string:
. The tag name <tag name> string must also be specified. The REFERENCES() function returns True (.T.) or False (.F.), depending on the success of the lookup operation. Please see the RLOOKUP() function for cross-table lookups using single indexes (.ndx).

Example

open database southwind
use customers order customerid in 2
use orders in 1
? references(customerid,2)
.T.
? references(customerid,customers)
.T.
 
select customers
set order to address
select orders
// Specify the index tag string to search in non-master index
? references(customerid,2,"customerid")
.T.
? references(customerid,customers,"customerid")
.T.
 
select customers
use
select orders
// customers table is not currently open
? references(customerid,"customers","customerid")
.T.