Nbind
nbind
returns the number of indexes in an opened table. It is an integer variable present in the [G:abv] class associated with a table opened with the abv abbreviation.
Syntax
[G:ABV]nbind
ABV
is the abbreviation used to open the table.
Example
# Returns the properties of a table defined by TABLENAME parameter in a JSON feed
Subprog TABLE_DESCRIPTION(TABLENAME,RESULT)
Variable Clbfile RESULT()
Value Char TABLENAME()
If clalev([XXX]) : LogicClose File [XXX] : Endif : Local File =TABLENAME [XXX]
RESULT="{"
Append RESULT,' "table" : "' + TABLENAME + '",'
Append RESULT,' "columns_number" : ' + num$([G:XXX]nbzon) + ','
# List of column (we skip I=0)
Append RESULT,' "columns" : ['
For I=1 To [G:XXX]nbzon-1
Append RESULT,string$(I>1,",") + '"' + [G:XXX]adxfname(I) + '"'
Next I
Append RESULT,' ],'
Append RESULT,' "index_number" : ' + num$([G:XXX]nbind) + ','
# List of indexes
Append RESULT,' "indexes" : ['
For I=1 To [G:XXX]nbind
Append RESULT, string$(I>1,",")+ '{'
Append RESULT, '"name":"' + [G:XXX]keyname(I-1) + '",'
Append RESULT, '"length":' + num$([G:XXX]keylen(I-1)) + ','
Append RESULT, '"duplicated":' + string$([G:XXX]keyuniq(I-1)=1,"true") + string$([G:XXX]keyuniq(I-1)=0,"false")
Append RESULT, '}'
Next I
Append RESULT,'],'
Append RESULT,'"record_length":'+num$([G:XXX]tairec)
Append RESULT,'}'
End
On the table "ACCESS", the result (normalized) of the JSON generated by this script is the following:{
"table": "ACCES",
"columns_number": 12,
"columns": [ "CODACC", "USR", "CONSUL", "EXEC", "MODIF", "PRFCOD", "CREUSR", "UPDUSR", "CREDATTIM", "UPDDATTIM", "AUUID" ],
"index_number": 2,
"indexes": [
{ "name": "CODACC", "length": 40, "duplicated": false },
{ "name": "PRFCOD", "length": 50, "duplicated": true }
],
"record_length": 109
}
See also
nbzon, adxfname, keyname, keylen, keyuniq, tairec.